mongoose-multi-cons

0.0.2 • Public • Published

handle multiple mongoose connections

Install

$ npm install --save mongoose-multi-cons

Usage

// mongoose connect method
function connect(uri) {
  return mongoose.createConnection(uri, options, function(err, res) {
    if (err)
      logger.error('Error connectiong to: ' + uri + '. ' + err);
    else
      logger.info('Successfully connected to: ' + uri);
  });
}

// init
var
  mongooseMultiCons = require('mongoose-multi-cons')(connect, function(err) {
    logger.error(err);
  });

// create connection
mongooseMultiCons.createConnection(uri, dbName);

// get connection
mongooseMultiCons.get(dbName);
$ npm install --save mongoose-multi-cons

License

MIT ©

Readme

Keywords

Package Sidebar

Install

npm i mongoose-multi-cons

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • erel