From 297b5906edf819eda7a23612498e82ea9ae7de4b Mon Sep 17 00:00:00 2001 From: pentode Date: Tue, 19 May 2015 14:55:06 -0400 Subject: [PATCH] add feature to define mongo client connect options via config.json --- package.json | 1 + src/database/mongo.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/package.json b/package.json index 278141c507..dabfe11799 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "templates.js": "^0.2.3", "uglify-js": "git+https://github.com/julianlam/UglifyJS2.git", "underscore": "~1.8.3", + "underscore.deep": "^0.5.1", "validator": "^3.30.0", "winston": "^0.9.0", "xregexp": "~2.0.0" diff --git a/src/database/mongo.js b/src/database/mongo.js index cc9bacec1c..9b0cd64842 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -7,8 +7,11 @@ async = require('async'), nconf = require('nconf'), session = require('express-session'), + _ = require('underscore'), db, mongoClient; + _.mixin(require('underscore.deep')); + module.questions = [ { name: 'mongo:host', @@ -88,6 +91,9 @@ poolSize: parseInt(nconf.get('mongo:poolSize'), 10) || 10 } }; + + connOptions = _.deepExtend((nconf.get('mongo:options') || {}), connOptions); + mongoClient.connect(connString, connOptions, function(err, _db) { if (err) { winston.error("NodeBB could not connect to your Mongo database. Mongo returned the following error: " + err.message);