@trejgun/mongo-bot-storage
mongo bot storage
Last updated 9 months ago by trejgun .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @trejgun/mongo-bot-storage 
SYNC missed versions from official npm registry.

USAGE

es5

var storage = require("@trejgun/mongo-bot-storage");
var MongoDbBotStorage = storage.MongoDbBotStorage;
var MongoDBStorageClient = storage.MongoDBStorageClient;

es6

import {MongoDbBotStorage, MongoDBStorageClient} from "@trejgun/mongo-bot-storage";

new native connection

bot.set("storage", new MongoDbBotStorage(new MongoDBStorageClient({
    url: "mongodb://localhost/mydb",
    mongoOptions: {}
})));

mongoose connection

const connection = mongoose.createConnection(/* ... */);
bot.set("storage", new MongoDbBotStorage(new MongoDBStorageClient({
    mongooseConnection: connection
})));

db connection

MongoClient.connect("mongodb://localhost/mydb", (error, db) => {
    bot.set("storage", new MongoDbBotStorage(new MongoDBStorageClient({db})));
});

promise connection

const dbPromise = new Promise((resolve, reject) => {
	MongoClient.connect("mongodb://localhost/mydb", (error, db) => {
		if (error) {
			reject(error);
		} else {
			resolve(db);
		}
	});
});

bot.set("storage", new MongoDbBotStorage(new MongoDBStorageClient({dbPromise})));

Current Tags

  • 0.0.5                                ...           latest (9 months ago)

1 Versions

  • 0.0.5                                ...           9 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 5
Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |