koa-mongo-db
v3.0.3
Published
Get db connection in context
Downloads
34
Readme
koa-mongo-db
Get db connection in context
Install
$ npm install --save koa-mongo-db
Usage
use version 1 for koa 1
var app = require('koa')();
var koaMongoDb = require('koa-mongo-db');
app.use(koaMongoDb('mongodb://localhost/test'));
app.get('/', function * (next) {
this.db // => Db object
});
API
koaMongoDb(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.
License
MIT
Thanks to floatdrop for the original express-mongo-db.