0.0.2 • Published 10 years ago

mongoose-multi-cons v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

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 ©