ookamiiixd / baileys-store Goto Github PK
View Code? Open in Web Editor NEWMinimal Baileys data storage for your favorite DBMS built with Prisma
License: MIT License
Minimal Baileys data storage for your favorite DBMS built with Prisma
License: MIT License
hi, I do individual messaging.
however, after I checked the terminal an error appeared like the following:
{"level":50,"time":1674705594919,"pid":183106,"hostname":"casudin-local","err":{"type":"PrismaClientKnownRequestError","message":"\nInvalid
model.create()invocation in\n/home/casudin/www/project/wa-api-new/node_modules/@ookamiiixd/baileys-store/dist/handlers/message.js:79:27\n\n 76 },\n 77 },\n 78 }),\nโ 79 model.create(\nUnique constraint failed on the constraint:
PRIMARY","stack":"Error: \nInvalid
model.create()invocation in\n/home/casudin/www/project/wa-api-new/node_modules/@ookamiiixd/baileys-store/dist/handlers/message.js:79:27\n\n 76 },\n 77 },\n 78 }),\nโ 79 model.create(\nUnique constraint failed on the constraint:
PRIMARY\n at RequestHandler.handleRequestError (/home/casudin/www/project/wa-api-new/node_modules/@prisma/client/runtime/index.js:34869:13)\n at RequestHandler.handleAndLogRequestError (/home/casudin/www/project/wa-api-new/node_modules/@prisma/client/runtime/index.js:34841:12)\n at RequestHandler.request (/home/casudin/www/project/wa-api-new/node_modules/@prisma/client/runtime/index.js:34836:12)\n at async PrismaClient._request (/home/casudin/www/project/wa-api-new/node_modules/@prisma/client/runtime/index.js:35926:16)\n at async Promise.all (index 1)\n at async EventEmitter.update (/home/casudin/www/project/wa-api-new/node_modules/@ookamiiixd/baileys-store/dist/handlers/message.js:68:17)","code":"P2002","clientVersion":"4.7.1","meta":{"target":"PRIMARY"}},"msg":"An error occured during message update"}
not everyone is fan mysql
i think adding support of postgres and sqlite will help many
[email protected] build
tsc
src/controllers/chat.ts:16:12 - error TS7006: Parameter 'c' implicitly has an 'any' type.
16 ).map((c) => serializePrisma(c));
~
src/controllers/chat.ts:42:12 - error TS7006: Parameter 'm' implicitly has an 'any' type.
42 ).map((m) => serializePrisma(m));
~
src/controllers/message.ts:19:12 - error TS7006: Parameter 'm' implicitly has an 'any' type.
19 ).map((m) => serializePrisma(m));
~
Found 3 errors in 2 files.
Errors Files
2 src/controllers/chat.ts:16
1 src/controllers/message.ts:19
{
"level": 50,
"time": 1678108145766,
"pid": 1619577,
"hostname": "host",
"err": {
"type": "TypeError",
"message": "Cannot read properties of undefined (reading 'push')",
"stack": "TypeError: Cannot read properties of undefined (reading 'push')\n at EventEmitter.updateParticipant (/home/whatsapp/whatsapp/node_modules/@ookamiiixd/baileys-store/dist/handlers/group-metadata.js:55:43)"
},
"msg": "An error occured during group participants update"
}
Library fails to update contact when baileys sends contacts.update
with contact that doesn't exist in database.
{
"level": 50,
"time": 1678092911539,
"pid": 1610218,
"hostname": "host",
"err": {
"type": "PrismaClientKnownRequestError",
"message": "\nInvalid `model.update()` invocation in\n/home/whatsapp/new/node_modules/@ookamiiixd/baileys-store/dist/handlers/contact.js:57:29\n\n 54 const update = async (updates) => {\n 55 for (const update of updates) {\n 56 try {\n\u2192 57 await model.update(\nAn operation failed because it depends on one or more records that were required but not found. Record to update not found.",
"stack": "Error: \nInvalid `model.update()` invocation in\n/home/whatsapp/new/node_modules/@ookamiiixd/baileys-store/dist/handlers/contact.js:57:29\n\n 54 const update = async (updates) => {\n 55 for (const update of updates) {\n 56 try {\n\u2192 57 await model.update(\nAn operation failed because it depends on one or more records that were required but not found. Record to update not found.\n at Zr.handleRequestError (/home/whatsapp/new/node_modules/@prisma/client/runtime/library.js:171:6414)\n at Zr.handleAndLogRequestError (/home/whatsapp/new/node_modules/@prisma/client/runtime/library.js:171:5948)\n at Zr.request (/home/whatsapp/new/node_modules/@prisma/client/runtime/library.js:171:5786)\n at async t._request (/home/whatsapp/new/node_modules/@prisma/client/runtime/library.js:174:10455)\n at async EventEmitter.update (/home/whatsapp/new/node_modules/@ookamiiixd/baileys-store/dist/handlers/contact.js:57:17)",
"code": "P2025",
"clientVersion": "4.11.0",
"meta": {
"cause": "Record to update not found."
}
},
"msg": "An error occured during contact update"
}
Steps to reproduce:
git clone [email protected]:ookamiiixd/baileys-store.git
cd baileys-store
docker run --rm --name wapostgres -p 5444:5432 -e POSTGRES_PASSWORD=1234 -d postgres
npm i
echo 'DATABASE_URL="postgresql://postgres:1234@localhost:5444/wa"' > .env
sed -i 's/mysql/postgresql/g' prisma/schema.prisma
npx prisma migrate dev
Output from prisma:
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "wa", schema "public" at "localhost:5444"
Error: Prisma schema validation - (query-engine-node-api library)
Error code: P1012
error: Error parsing attribute "@@unique": The given constraint name `unique_id_per_session_id` has to be unique in the following namespace: global for primary key, indexes and unique constraints. Please provide a different name using the `map` argument.
--> schema.prisma:60
|
59 |
60 | @@unique([sessionId, id], map: "unique_id_per_session_id")
|
error: Error parsing attribute "@@unique": The given constraint name `unique_id_per_session_id` has to be unique in the following namespace: global for primary key, indexes and unique constraints. Please provide a different name using the `map` argument.
--> schema.prisma:74
|
73 |
74 | @@unique([sessionId, id], map: "unique_id_per_session_id")
|
error: Error parsing attribute "@@unique": The given constraint name `unique_id_per_session_id` has to be unique in the following namespace: global for primary key, indexes and unique constraints. Please provide a different name using the `map` argument.
--> schema.prisma:97
|
96 |
97 | @@unique([sessionId, id], map: "unique_id_per_session_id")
|
error: Error parsing attribute "@@unique": The given constraint name `unique_id_per_session_id` has to be unique in the following namespace: global for primary key, indexes and unique constraints. Please provide a different name using the `map` argument.
--> schema.prisma:160
|
159 |
160 | @@unique([sessionId, id], map: "unique_id_per_session_id")
|
Validation Error Count: 4
[Context: getDmmf]
Prisma CLI Version : 4.7.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.