baileys-store-kuy
v1.0.0
Published
Minimal Baileys data storage for your favorite DBMS built with Sequelize
Downloads
3
Readme
Baileys Store
Minimal 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
Requirements
- sequelize version 6.37.x or higher
- Baileys version 6.7.x or higher
Supported Databases
- MySQL and PostgreSQL database should support the default schema out of the box
- For CockroachDB, you need to do this small change in the schema file
Installation
# Using npm
npm i baileys-store-kuy
# Using yarn
yarn add baileys-store-kuy
Setup
Before you can actually use this library, you have to setup your database first
- Copy the
.env.example
file from this repository or from thenode_modules
directory (should be located atnode_modules/baileys-store-kuy/.env.example
). Rename it into.env
and then update your connection url in theDATABASE_URL
field
Usage
import pino from 'pino';
import makeWASocket from '@whiskeysockets/baileys';
import { Sequelize } from 'sequelize';
import { Store } from 'baileys-store-kuy';
const logger = pino();
const sequelize = new Sequelize();
// Create a store and start listening to the events
const store = new Store('unique-session-id-here', socket.ev);
// That's it, you can now query from the sequelize without having to worry about handling the events
const messages = sequelize.message.finAll();
Contributing
PRs, issues, suggestions, etc are welcome. Please kindly open a new issue to discuss it