|
|
|
@ -47,13 +47,8 @@
|
|
|
|
|
|
|
|
|
|
module.init = function (callback) {
|
|
|
|
|
callback = callback || function () { };
|
|
|
|
|
var mongoClient;
|
|
|
|
|
try {
|
|
|
|
|
mongoClient = require('mongodb').MongoClient;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
winston.error('Unable to initialize MongoDB! Is MongoDB installed? Error :' + err.message);
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mongoClient = require('mongodb').MongoClient;
|
|
|
|
|
|
|
|
|
|
var usernamePassword = '';
|
|
|
|
|
if (nconf.get('mongo:username') && nconf.get('mongo:password')) {
|
|
|
|
@ -90,7 +85,7 @@
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
connOptions = _.deepExtend((nconf.get('mongo:options') || {}), connOptions);
|
|
|
|
|
connOptions = _.deepExtend(connOptions, nconf.get('mongo:options') || {});
|
|
|
|
|
|
|
|
|
|
mongoClient.connect(connString, connOptions, function (err, _db) {
|
|
|
|
|
if (err) {
|
|
|
|
@ -110,10 +105,7 @@
|
|
|
|
|
|
|
|
|
|
if (nconf.get('mongo:password') && nconf.get('mongo:username')) {
|
|
|
|
|
db.authenticate(nconf.get('mongo:username'), nconf.get('mongo:password'), function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
callback();
|
|
|
|
|
callback(err);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
winston.warn('You have no mongo password setup!');
|
|
|
|
|