mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
fixes for dual database; moved dependency definitions into the database object
This commit is contained in:
@@ -89,7 +89,9 @@ function getSecondaryDatabaseModules(config, next) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function(err, config, allowedDBs, callback) {
|
module.exports = function(err, config, databases, callback) {
|
||||||
|
var allowedDBs = Object.keys(databases);
|
||||||
|
|
||||||
allowedDBs.forEach(function(db) {
|
allowedDBs.forEach(function(db) {
|
||||||
questions[db] = require('./../src/database/' + db).questions;
|
questions[db] = require('./../src/database/' + db).questions;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,17 @@ var async = require('async'),
|
|||||||
nconf = require('nconf'),
|
nconf = require('nconf'),
|
||||||
utils = require('../public/src/utils.js'),
|
utils = require('../public/src/utils.js'),
|
||||||
|
|
||||||
ALLOWED_DATABASES = ['redis', 'mongo', 'level'];
|
DATABASES = {
|
||||||
|
"redis": {
|
||||||
|
"dependencies": ["redis", "connect-redis@~1.4"]
|
||||||
|
},
|
||||||
|
"mongo": {
|
||||||
|
"dependencies": ["mongodb", "connect-mongo"]
|
||||||
|
},
|
||||||
|
"level": {
|
||||||
|
"dependencies": ["levelup", "leveldown", "connect-leveldb"]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var install = {},
|
var install = {},
|
||||||
@@ -137,12 +147,12 @@ function setupConfig(next) {
|
|||||||
'default': nconf.get('secondary_database') || 'none'
|
'default': nconf.get('secondary_database') || 'none'
|
||||||
}, function(err, dbConfig) {
|
}, function(err, dbConfig) {
|
||||||
config.secondary_database = dbConfig.secondary_database;
|
config.secondary_database = dbConfig.secondary_database;
|
||||||
configureDatabases(err, config, ALLOWED_DATABASES, function(err, config) {
|
configureDatabases(err, config, DATABASES, function(err, config) {
|
||||||
completeConfigSetup(err, config, next);
|
completeConfigSetup(err, config, next);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
configureDatabases(err, config, ALLOWED_DATABASES, function(err, config) {
|
configureDatabases(err, config, DATABASES, function(err, config) {
|
||||||
completeConfigSetup(err, config, next);
|
completeConfigSetup(err, config, next);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -160,7 +170,7 @@ function setupConfig(next) {
|
|||||||
config[question.name] = install.values[question.name] || question['default'] || '';
|
config[question.name] = install.values[question.name] || question['default'] || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
configureDatabases(null, config, ALLOWED_DATABASES, function(err, config) {
|
configureDatabases(null, config, DATABASES, function(err, config) {
|
||||||
completeConfigSetup(err, config, next);
|
completeConfigSetup(err, config, next);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -208,18 +218,9 @@ function setupDatabase(server_conf, next) {
|
|||||||
next(err);
|
next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(server_conf.database) {
|
packages = packages.concat(DATABASES[server_conf.database].dependencies);
|
||||||
case 'redis':
|
if (server_conf.secondary_database) {
|
||||||
packages = packages.concat(['redis', 'connect-redis@~1.4']);
|
packages = packages.concat(DATABASES[server_conf.secondary_database].dependencies);
|
||||||
break;
|
|
||||||
|
|
||||||
case 'mongo':
|
|
||||||
packages = packages.concat(['mongodb', 'connect-mongo']);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'level':
|
|
||||||
packages = packages.concat(['levelup', 'leveldown', 'connect-leveldb']);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
npm.commands.install(packages, function(err) {
|
npm.commands.install(packages, function(err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user