Ping / src /baileys /db.ts
understanding's picture
Upload 41 files
ba5c923 verified
raw
history blame contribute delete
532 Bytes
import { MongoClient } from "mongodb";
import { AuthenticationCreds } from "@whiskeysockets/baileys";
const dbName = "whatsapp";
const collectionName = "authState";
interface AuthDocument extends Document {
_id: string;
creds?: AuthenticationCreds;
}
async function connectDB() {
const client = new MongoClient(process.env.MONGO_URL || "");
await client.connect();
const db = client.db(dbName);
const collection = db.collection<AuthDocument>(collectionName);
return { client, collection };
}
export { connectDB };