hide secondary_database option behind "advanced" setup flag
parent
ffe9afc3c4
commit
d5b5dd6fa5
@ -1,14 +1,35 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
var nconf = require('nconf'),
|
var nconf = require('nconf'),
|
||||||
databaseType = nconf.get('database'),
|
primaryDBConfig = nconf.get('database'),
|
||||||
winston = require('winston');
|
secondaryDBConfig = nconf.get('secondary_database'),
|
||||||
|
secondaryModules = nconf.get('secondary_db_modules'),
|
||||||
|
winston = require('winston'),
|
||||||
|
|
||||||
|
ALLOWED_MODULES = ['hash', 'list', 'sets', 'sorted'];
|
||||||
|
|
||||||
if(!databaseType) {
|
if(!primaryDBConfig) {
|
||||||
winston.info('Database type not set! Run node app --setup');
|
winston.info('Database type not set! Run node app --setup');
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
var db = require('./database/' + databaseType);
|
function setupSecondaryDB() {
|
||||||
|
var secondaryDB = require('./database/' + secondaryDBConfig);
|
||||||
|
|
||||||
|
secondaryModules = secondaryModules.split(/,\s*/);
|
||||||
|
|
||||||
|
for (var module in secondaryModules) {
|
||||||
|
if (secondaryModules.hasOwnProperty(module) && ALLOWED_MODULES.indexOf(module) !== -1) {
|
||||||
|
primaryDB[module] = secondaryDB[module];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var primaryDB = require('./database/' + primaryDBConfig);
|
||||||
|
|
||||||
|
if (secondaryDBConfig && secondaryModules) {
|
||||||
|
setupSecondaryDB();
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = db;
|
module.exports = primaryDB;
|
Loading…
Reference in New Issue