2.0.5 • Published 6 months ago

mrx-baileys-store v2.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

🚨 NOTICE: @whiskeysockets/baileys If you use bailey store in this version it is already updated with the lib https://github.com/WhiskeySockets/Baileys . Hope that helps ❤


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

  • Prisma version 4.7.x or higher
  • Baileys version 5.x.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
model Session {
  pkId      BigInt    @id @default(autoincrement())
  sessionId String
  id        String
-  data      String @db.Text
+  data      String

  @@unique([sessionId, id], map: "unique_id_per_session_id_session")
  @@index([sessionId])
}
  • For MongoDB, you need to follow this convention and update the pkId field. Then follow the previous CockroachDB guide
  • SQLite and SQL Server database are not supported since they didn't support Prisma's JSON scalar type

Installation

# Using npm
npm i mrx-baileys-store

Setup

import pino from 'pino';
import makeWASocket from '@whiskeysockets/baileys';
import { PrismaClient } from '@prisma/client';
import { initStore, Store } from 'mrx-baileys-store';

const logger = pino();
const socket = makeWASocket();
const prisma = new PrismaClient();

// You only need to run this once
initStore({
  prisma, // Prisma client instance
  logger, // Pino logger (Optional)
});

// 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 prisma client without having to worry about handling the events
const messages = prisma.message.findMany();
2.0.9

7 months ago

2.0.10

6 months ago

2.0.8

7 months ago

2.0.7

8 months ago

2.0.6

8 months ago

2.0.5

11 months ago

2.0.4

11 months ago

2.0.3

11 months ago

2.0.2

11 months ago

2.0.1

11 months ago