Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/floatdrop/express-mongo-db
Get db connection in request object
https://github.com/floatdrop/express-mongo-db
Last synced: 3 months ago
JSON representation
Get db connection in request object
- Host: GitHub
- URL: https://github.com/floatdrop/express-mongo-db
- Owner: floatdrop
- License: mit
- Created: 2014-01-20T09:50:44.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2020-04-13T15:58:49.000Z (almost 5 years ago)
- Last Synced: 2024-10-10T04:05:12.015Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 35.2 KB
- Stars: 79
- Watchers: 3
- Forks: 17
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# express-mongo-db [![Build Status](https://travis-ci.org/floatdrop/express-mongo-db.svg?branch=master)](https://travis-ci.org/floatdrop/express-mongo-db)
> Get db connection in request
## Install
```
$ npm install --save express-mongo-db
```## Usage
```js
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](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)