I migrated all my storages to monorepo, check it out: https://github.com/Satont/grammy-storages
Storage adapter that can be used to store your session data with MongoDB when using sessions.
Compatible with deno and node!
Node
npm install @satont/grammy-mongodb-storage --save
Deno
import {
ISession,
MongoDBAdapter,
} from "https://deno.land/x/grammy_mongodb_storage/mod.ts";
You can check examples folder, which contains deno and node examples.:
If you use Mongoose for operations with mongodb, you can still use this adapter. You need to get a native connection and use it:
import mongoose from "mongoose";
import MongoStorage from "@satont/grammy-mongodb-storage";
await mongoose.connect("mongodb://localhost:27017/test");
const collection = mongoose.connection.db.collection<MongoStorage.ISession>(
"sessions",
);
new MongoStorage.MongoDBAdapter({ collection });