make mongodb uri configurable

This commit is contained in:
Ivan Socolsky 2015-04-23 16:30:16 -03:00
parent c7ffacac93
commit fd542db4a6
2 changed files with 4 additions and 6 deletions

View File

@ -13,8 +13,7 @@ var config = {
storageOpts: {
mongoDb: {
host: 'localhost',
port: 27017,
uri: 'mongodb://localhost:27017/bws',
},
},
lockOpts: {

View File

@ -33,14 +33,13 @@ Storage.prototype.connect = function(opts, cb) {
if (this.db) return cb(null);
var config = opts.mongoDb || {};
var url = 'mongodb://' + (config.host || 'localhost') + ':' + (config.port ||  27017) + '/bws';
mongodb.MongoClient.connect(url, function(err, db) {
mongodb.MongoClient.connect(config.uri, function(err, db) {
if (err) {
log.error('Unable to connect to the mongoDB server.');
log.error('Unable to connect to the mongoDB server on ', config.uri);
return cb(err);
}
self.db = db;
console.log('Connection established to ', url);
console.log('Connection established to ', config.uri);
return cb(null);
});
};