Merge pull request #195 from isocolsky/ref/mongo_uri
make mongodb uri configurable
This commit is contained in:
commit
784e3d956c
|
@ -13,8 +13,7 @@ var config = {
|
|||
|
||||
storageOpts: {
|
||||
mongoDb: {
|
||||
host: 'localhost',
|
||||
port: 27017,
|
||||
uri: 'mongodb://localhost:27017/bws',
|
||||
},
|
||||
},
|
||||
lockOpts: {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue