dico-mongodb

0.0.1 • Public • Published

Dico-mongodb

This is a wrapper between the mongodb native driver and the dependency injection container dico.

You can Configure and use the mongodb native driver easily, and access it through the dico container.

Installation

$ npm install dico-mongodb

Usage

dico.load({
  'database': {
    'module': 'dico-mongodb',
    'url': 'mongodb://localhost:27017/test',
    'options': {
      'db': {
        'native_parser': false
      },
      'server': {
        'socketOptions': {
          'connectTimeoutMS': 500
        }
      },
      'replSet': {},
      'mongos': {}
    }
  },
  'database2': {
    'module': 'dico-mongodb',
    'url': 'mongodb://localhost:27017/test2'
  },
}, __dirname);

dico.get('@database', function(err, database) {
  if (err) return done(err);

  var collection = database.collection('test');
  collection.doStuff();
});

The url parameter accept any valid connection URL. The options parameter is optional and accept any options MongoClient#connect accepts.

Package Sidebar

Install

npm i dico-mongodb

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • guilro