mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
closes #6000
This commit is contained in:
@@ -34,7 +34,7 @@ function getDatabaseConfig(config, callback) {
|
|||||||
prompt.get(questions.redis, callback);
|
prompt.get(questions.redis, callback);
|
||||||
}
|
}
|
||||||
} else if (config.database === 'mongo') {
|
} 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);
|
callback(null, config);
|
||||||
} else {
|
} else {
|
||||||
prompt.get(questions.mongo, callback);
|
prompt.get(questions.mongo, callback);
|
||||||
@@ -68,6 +68,7 @@ function saveDatabaseConfig(config, databaseConfig, callback) {
|
|||||||
username: databaseConfig['mongo:username'],
|
username: databaseConfig['mongo:username'],
|
||||||
password: databaseConfig['mongo:password'],
|
password: databaseConfig['mongo:password'],
|
||||||
database: databaseConfig['mongo:database'],
|
database: databaseConfig['mongo:database'],
|
||||||
|
uri: databaseConfig['mongo:uri'],
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return callback(new Error('unknown database : ' + config.database));
|
return callback(new Error('unknown database : ' + config.database));
|
||||||
|
|||||||
@@ -8,37 +8,52 @@ var nconf = require('nconf');
|
|||||||
var session = require('express-session');
|
var session = require('express-session');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var semver = require('semver');
|
var semver = require('semver');
|
||||||
|
var prompt = require('prompt');
|
||||||
var db;
|
var db;
|
||||||
|
|
||||||
var mongoModule = module.exports;
|
var mongoModule = module.exports;
|
||||||
|
|
||||||
|
function isUriNotSpecified() {
|
||||||
|
return !prompt.history('mongo:uri').value;
|
||||||
|
}
|
||||||
|
|
||||||
mongoModule.questions = [
|
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',
|
name: 'mongo:host',
|
||||||
description: 'Host IP or address of your MongoDB instance',
|
description: 'Host IP or address of your MongoDB instance',
|
||||||
default: nconf.get('mongo:host') || '127.0.0.1',
|
default: nconf.get('mongo:host') || '127.0.0.1',
|
||||||
|
ask: isUriNotSpecified,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mongo:port',
|
name: 'mongo:port',
|
||||||
description: 'Host port of your MongoDB instance',
|
description: 'Host port of your MongoDB instance',
|
||||||
default: nconf.get('mongo:port') || 27017,
|
default: nconf.get('mongo:port') || 27017,
|
||||||
|
ask: isUriNotSpecified,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mongo:username',
|
name: 'mongo:username',
|
||||||
description: 'MongoDB username',
|
description: 'MongoDB username',
|
||||||
default: nconf.get('mongo:username') || '',
|
default: nconf.get('mongo:username') || '',
|
||||||
|
ask: isUriNotSpecified,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mongo:password',
|
name: 'mongo:password',
|
||||||
description: 'Password of your MongoDB database',
|
description: 'Password of your MongoDB database',
|
||||||
hidden: true,
|
|
||||||
default: nconf.get('mongo:password') || '',
|
default: nconf.get('mongo:password') || '',
|
||||||
|
hidden: true,
|
||||||
|
ask: isUriNotSpecified,
|
||||||
before: function (value) { value = value || nconf.get('mongo:password') || ''; return value; },
|
before: function (value) { value = value || nconf.get('mongo:password') || ''; return value; },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mongo:database',
|
name: 'mongo:database',
|
||||||
description: 'MongoDB database name',
|
description: 'MongoDB database name',
|
||||||
default: nconf.get('mongo:database') || 'nodebb',
|
default: nconf.get('mongo:database') || 'nodebb',
|
||||||
|
ask: isUriNotSpecified,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user