mongodb-express-req
v1.3.0
Published
Get db connection in request
Downloads
3
Readme
Get db connection in request
Install
$ npm install mongodb-express-req
Usage
var app = require('express')();
var expressMongoDb = require('mongodb-express-req');
app.use(expressMongoDb('mongodb://localhost/db_name'));
app.get('/', function (req, res, next) {
req.db // => Db object
req.db.collection('collection_name').insertOne({ email, password })
});
API
expressMongoDb(uri, [options])
uri
Required
Type: string
options
All options from MongoClient are accepted as well.
property
Type: String
Default: db
Property on request
object in which db connection will be stored.
Credentials
Fork of titanscouting/mongo-express-req
License
MIT © Roman Shmigelsky