mongo-factory
v1.0.0
Published
A very simple mongo connection pool manager
Downloads
169
Maintainers
Readme
The purpose of this module is to manage mongo connection pools without creating a new connection pool in every file.
You can require this module in as many files as you want and every time you call
mongoFactory.getConnection
it returns a connection if one exists for the connection string passed in, or it instantiates the connection pool and then returns a connection.
Usage
var mongoFactory = require('mongo-factory');
mongoFactory.getConnection('mongodb://localhost:27017')
.then(function(db) {
// Use mongo's "db" object as you normally would.
db.collection.find()...
})
.catch(function(err) {
console.error(err);
});
API
getConnection(mongodbConnectionString)
The only parameter is a connection string for a MongoDB connection.
ObjectId
Exposes the MongoDB ObjectID function.
Contributing
- Clone project and run
npm install
- Add feature(s)
- Add tests for it
- Submit pull request
Enjoy!