You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/src/database.js

35 lines
877 B
JavaScript

"use strict";
11 years ago
var nconf = require('nconf'),
primaryDBConfig = nconf.get('database'),
secondaryDBConfig = nconf.get('secondary_database'),
secondaryModules = nconf.get('secondary_db_modules'),
winston = require('winston'),
ALLOWED_MODULES = ['hash', 'list', 'sets', 'sorted'];
if(!primaryDBConfig) {
winston.info('Database type not set! Run node app --setup');
process.exit();
}
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();
}
11 years ago
module.exports = primaryDB;