express-mongo-db

Get db connection in request

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
express-mongo-db
7872.0.46 years ago10 years agoMinified + gzip package size for express-mongo-db in KB

Readme

express-mongo-db Build Status
Get db connection in request

Install

$ npm install --save express-mongo-db

Usage

var app = require('express')();

var expressMongoDb = require('express-mongo-db');
app.use(expressMongoDb('mongodb://localhost/test'));

app.get('/', function (req, res, next) {
	req.db // => Db object
});

API

expressMongoDb(uri, options)

uri

Required
Type: string
Connection string uri.

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.

License

MIT © Vsevolod Strukchinsky