v1.18.x
Barış Soner Uşaklı 7 years ago
parent 2929d4b1df
commit 7ad4420b6a

@ -34,7 +34,7 @@ function getDatabaseConfig(config, callback) {
prompt.get(questions.redis, callback);
}
} else if (config.database === 'mongo') {
if (config['mongo:host'] && config['mongo:port']) {
if ((config['mongo:host'] && config['mongo:port']) || config['mongo:uri']) {
callback(null, config);
} else {
prompt.get(questions.mongo, callback);
@ -68,6 +68,7 @@ function saveDatabaseConfig(config, databaseConfig, callback) {
username: databaseConfig['mongo:username'],
password: databaseConfig['mongo:password'],
database: databaseConfig['mongo:database'],
uri: databaseConfig['mongo:uri'],
};
} else {
return callback(new Error('unknown database : ' + config.database));

@ -8,37 +8,52 @@ var nconf = require('nconf');
var session = require('express-session');
var _ = require('lodash');
var semver = require('semver');
var prompt = require('prompt');
var db;
var mongoModule = module.exports;
function isUriNotSpecified() {
return !prompt.history('mongo:uri').value;
}
mongoModule.questions = [
{
name: 'mongo:uri',
description: 'MongoDB connection URI: (leave blank if you wish to specify host, port, username/password and database individually)\nFormat: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]',
default: nconf.get('mongo:uri') || '',
},
{
name: 'mongo:host',
description: 'Host IP or address of your MongoDB instance',
default: nconf.get('mongo:host') || '127.0.0.1',
ask: isUriNotSpecified,
},
{
name: 'mongo:port',
description: 'Host port of your MongoDB instance',
default: nconf.get('mongo:port') || 27017,
ask: isUriNotSpecified,
},
{
name: 'mongo:username',
description: 'MongoDB username',
default: nconf.get('mongo:username') || '',
ask: isUriNotSpecified,
},
{
name: 'mongo:password',
description: 'Password of your MongoDB database',
hidden: true,
default: nconf.get('mongo:password') || '',
hidden: true,
ask: isUriNotSpecified,
before: function (value) { value = value || nconf.get('mongo:password') || ''; return value; },
},
{
name: 'mongo:database',
description: 'MongoDB database name',
default: nconf.get('mongo:database') || 'nodebb',
ask: isUriNotSpecified,
},
];

Loading…
Cancel
Save