1.1.0 • Published 4 years ago

@satont/grammy-mongodb-storage v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years 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 @satont/grammy-mongodb-storage --save

Deno

import {
  ISession,
  MongoDBAdapter,
} from "https://x.nest.land/grammy-mongodb-storage@1.0.1/src/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 });