https://github.com/titanscouting/mongo-express-req
Get Mongo DB in express vars
https://github.com/titanscouting/mongo-express-req
Last synced: over 1 year ago
JSON representation
Get Mongo DB in express vars
- Host: GitHub
- URL: https://github.com/titanscouting/mongo-express-req
- Owner: titanscouting
- License: mit
- Created: 2020-07-10T15:05:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-31T17:24:14.000Z (over 3 years ago)
- Last Synced: 2025-01-22T23:41:13.617Z (over 1 year ago)
- Language: JavaScript
- Size: 224 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# mongo-express-req [](https://travis-ci.org/floatdrop/mongo-express-req)
> Get db connection in request
## Install
```
$ npm install --save mongo-express-req
```
## Usage
```js
var app = require('express')();
var expressMongoDb = require('mongo-express-req');
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](http://docs.mongodb.org/manual/reference/connection-string/).
#### options
All options from [MongoClient](http://mongodb.github.io/node-mongodb-native/2.0/api/MongoClient.html) are accepted as well.
##### property
Type: `String`
Default: `db`
Property on `request` object in which db connection will be stored.
## License
MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop) and [Dev Singh](http://github.com/devksingh4)