2.4.2 • Published 2 months ago

@grammyjs/storage-mongodb v2.4.2

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

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 @grammyjs/storage-mongodb --save

Deno

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

Usage

You can see examples/ which contains both 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 { MongoDBAdapter, ISession } from "@grammyjs/storage-mongodb";

await mongoose.connect("mongodb://localhost:27017/test");

const collection = mongoose.connection.db.collection<ISession>(
  "sessions",
);

bot.use(session({
    initial: (): SessionData => ({
        pizzaCount: 0,
    }),
    storage: new MongoDBAdapter({ collection }),
}))
2.4.2

2 months ago

2.4.1

5 months ago

2.3.2

8 months ago

2.4.0

7 months ago

2.3.1

8 months ago

2.3.0

11 months ago

2.2.0

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.2

1 year ago

2.0.0

2 years ago