{"_id":"@bahriid/baileys-store","name":"@bahriid/baileys-store","dist-tags":{"latest":"1.0.0-beta.1"},"versions":{"1.0.0-beta.1":{"name":"@bahriid/baileys-store","version":"1.0.0-beta.1","description":"Minimal Baileys data storage for your favorite DBMS built with Prisma","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/bahriid/baileys-store.git"},"author":{"name":"Bahri","url":"https://github.com/bahriid"},"license":"MIT","scripts":{"build":"tsc","typecheck":"tsc --noEmit","lint":"eslint .","format":"prettier . --write"},"devDependencies":{"@prisma/client":"^4.7.1","@types/node":"^18.11.10","@typescript-eslint/eslint-plugin":"^5.45.0","@typescript-eslint/parser":"^5.45.0","@whiskeysockets/baileys":"^6.2.1","eslint":"^8.29.0","eslint-config-prettier":"^8.5.0","prettier":"^2.8.0","prisma":"^4.7.1","ts-node":"^10.9.1","typescript":"^4.9.3"},"dependencies":{"tiny-invariant":"^1.3.1"},"peerDependencies":{"@prisma/client":"^4.7.0","@whiskeysockets/baileys":"^6.2.1"},"bugs":{"url":"https://github.com/bahriid/baileys-whiskeysockets-store/issues"},"homepage":"https://github.com/bahriid/baileys-whiskeysockets-store#readme","licenseText":"MIT License\n\nCopyright (c) 2022 Royhan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","_id":"@bahriid/baileys-store@1.0.0-beta.1","dist":{"shasum":"623f819bbec6b562c78b211d297d87692962afa8","integrity":"sha512-uEMTUJeIWTIkNfEjP949cleyIgZ6B8G7e5n2nG1MPcjjoieBav/ZJGcVV3jGnpDx9wLfNtMQpLocBSYRDo7iQg==","tarball":"https://registry.npmjs.org/@bahriid/baileys-store/-/baileys-store-1.0.0-beta.1.tgz","fileCount":29,"unpackedSize":39874,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDXo/JV3cCviJAulY8WiwjiGX6GGNaeB/ZbdEkI+r+2UAiEAvIu83wGtP3X4oBFe0hfvEUtkDTZ2ojwHWDyFUe6XmR4="}]},"_npmUser":{"name":"bahriid","email":"aribahri15@gmail.com"},"directories":{},"maintainers":[{"name":"bahriid","email":"aribahri15@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/baileys-store_1.0.0-beta.1_1686402380157_0.8129097557127887"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-10T13:06:20.094Z","1.0.0-beta.1":"2023-06-10T13:06:20.363Z","modified":"2023-06-10T13:06:20.538Z"},"maintainers":[{"name":"bahriid","email":"aribahri15@gmail.com"}],"description":"Minimal Baileys data storage for your favorite DBMS built with Prisma","homepage":"https://github.com/bahriid/baileys-whiskeysockets-store#readme","repository":{"type":"git","url":"git+https://github.com/bahriid/baileys-store.git"},"author":{"name":"Bahri","url":"https://github.com/bahriid"},"bugs":{"url":"https://github.com/bahriid/baileys-whiskeysockets-store/issues"},"license":"MIT","readme":"# Baileys Store\n\nMinimal Baileys data storage for your favorite DBMS built with Prisma. This library is a simple handler for Baileys event emitter that will listen and update your data in the database\n\n## Requirements\n\n- **Prisma** version **4.7.x** or higher\n- **Baileys** version **5.x.x** or higher\n\n## Supported Databases\n\n- MySQL and PostgreSQL database should support the default schema out of the box\n- For CockroachDB, you need to do this small change in the schema file\n\n```diff\nmodel Session {\n  pkId      BigInt    @id @default(autoincrement())\n  sessionId String\n  id        String\n-  data      String @db.Text\n+  data      String\n\n  @@unique([sessionId, id], map: \"unique_id_per_session_id_session\")\n  @@index([sessionId])\n}\n```\n\n- For MongoDB, you need to follow [this convention](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference?query=getdmff&page=1#mongodb-10) and update the `pkId` field. Then follow the previous CockroachDB guide\n- SQLite and SQL Server database are not supported since they didn't support Prisma's `JSON` scalar type\n\n## Installation\n\n```bash\n# Using npm\nnpm i @bahriid/baileys-store\n\n# Using yarn\nyarn add @bahriid/baileys-store\n```\n\n## Setup\n\nBefore you can actually use this library, you have to setup your database first\n\n1. Copy the `.env.example` file from this repository or from the `node_modules` directory (should be located at `node_modules/@bahriid/baileys-store/.env.example`). Rename it into `.env` and then update your [connection url](https://www.prisma.io/docs/reference/database-reference/connection-urls) in the `DATABASE_URL` field\n2. Copy the `prisma` directory from this repository or from the `node_modules` directory (should be located at `node_modules/@bahriid/baileys-store/prisma/`). Additionaly, you may want to update your `provider` in the `schema.prisma` file if you're not using MySQL database\n3. Run your [migration](https://www.prisma.io/docs/reference/api-reference/command-reference#prisma-migrate)\n\n## Usage\n\n```ts\nimport pino from 'pino';\nimport makeWASocket from '@whiskeysockets/baileys';\nimport { PrismaClient } from '@prisma/client';\nimport { initStore, Store } from '@bahriid/baileys-store';\n\nconst logger = pino();\nconst socket = makeWASocket();\nconst prisma = new PrismaClient();\n\n// You only need to run this once\ninitStore({\n  prisma, // Prisma client instance\n  logger, // Pino logger (Optional)\n});\n\n// Create a store and start listening to the events\nconst store = new Store('unique-session-id-here', socket.ev);\n\n// That's it, you can now query from the prisma client without having to worry about handling the events\nconst messages = prisma.message.findMany();\n```\n\n## Contributing\n\nPRs, issues, suggestions, etc are welcome. Please kindly open a new issue to discuss it\n","readmeFilename":"README.md"}