From 5e0de4b8fbed018877657fb71ea4c03bed382f88 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 10 Mar 2017 12:21:59 +0300 Subject: [PATCH] closes #5517 --- src/database/mongo.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/database/mongo.js b/src/database/mongo.js index bb3d9f05c2..8e6494ffd7 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -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!');