forgot to export helpers as well for secondary db

v1.18.x
psychobunny 11 years ago
parent 290e348851
commit 8a1f6eb43e

@ -1,21 +1,21 @@
"use strict"; "use strict";
var nconf = require('nconf'), var nconf = require('nconf'),
primaryDBConfig = nconf.get('database'), primaryDBName = nconf.get('database'),
secondaryDBConfig = nconf.get('secondary_database'), secondaryDBName = nconf.get('secondary_database'),
secondaryModules = nconf.get('secondary_db_modules'), secondaryModules = nconf.get('secondary_db_modules'),
winston = require('winston'), winston = require('winston'),
async = require('async'), async = require('async'),
ALLOWED_MODULES = ['hash', 'list', 'sets', 'sorted']; ALLOWED_MODULES = ['hash', 'list', 'sets', 'sorted'];
if(!primaryDBConfig) { if(!primaryDBName) {
winston.info('Database type not set! Run node app --setup'); winston.info('Database type not set! Run node app --setup');
process.exit(); process.exit();
} }
function setupSecondaryDB() { function setupSecondaryDB() {
var secondaryDB = require('./database/' + secondaryDBConfig); var secondaryDB = require('./database/' + secondaryDBName);
secondaryModules = secondaryModules.split(/,\s*/); secondaryModules = secondaryModules.split(/,\s*/);
@ -26,7 +26,8 @@ function setupSecondaryDB() {
} }
var primaryDBinit = primaryDB.init, var primaryDBinit = primaryDB.init,
primaryDBclose = primaryDB.close; primaryDBclose = primaryDB.close,
primaryDBhelpers = primaryDB.helpers;
primaryDB.init = function(callback) { primaryDB.init = function(callback) {
async.parallel([primaryDBinit, secondaryDB.init], callback); async.parallel([primaryDBinit, secondaryDB.init], callback);
@ -35,12 +36,16 @@ function setupSecondaryDB() {
primaryDB.close = function(callback) { primaryDB.close = function(callback) {
async.parallel([primaryDBclose, secondaryDB.close], callback); async.parallel([primaryDBclose, secondaryDB.close], callback);
}; };
primaryDB.helpers = {};
primaryDB.helpers[primaryDBName] = primaryDBhelpers[primaryDBName];
primaryDB.helpers[secondaryDBName] = secondaryDB.helpers[secondaryDBName];
} }
var primaryDB = require('./database/' + primaryDBConfig); var primaryDB = require('./database/' + primaryDBName);
if (secondaryDBConfig && secondaryModules) { if (secondaryDBName && secondaryModules) {
setupSecondaryDB(); setupSecondaryDB();
} }

@ -106,5 +106,7 @@
redisClient.quit(); redisClient.quit();
}; };
module.helpers = module.helpers || {};
module.helpers.level = require('./mongo/helpers');
}(exports)); }(exports));

Loading…
Cancel
Save