Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Satont/grammy-mongodb-storage

Repository files navigation

ARCHIVED!!!

I migrated all my storages to monorepo, check it out: https://github.com/Satont/grammy-storages

MongoDB storage adapter for grammY

Storage adapter that can be used to store your session data with MongoDB when using sessions.

Compatible with deno and node!

Installation

Node

npm install @satont/grammy-mongodb-storage --save

Deno

import {
  ISession,
  MongoDBAdapter,
} from "https://deno.land/x/grammy_mongodb_storage/mod.ts";

Usage

You can check examples folder, which contains deno and node examples.:

Mongoose

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 });