Get db connection in request
$ npm install mongodb-express-req
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 })
});
Required
Type: string
All options from MongoClient are accepted as well.
Type: String
Default: db
Property on request
object in which db connection will be stored.
Fork of titanscouting/mongo-express-req
MIT © Roman Shmigelsky