Merge pull request #1811 from strapi/fix/srv

Fix srv
This commit is contained in:
Jim LAURIE 2018-08-27 14:06:06 +02:00 committed by GitHub
commit 8983521eb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -145,14 +145,14 @@ module.exports = (scope, cb) => {
when: !hasDatabaseConfig && scope.client.database === 'mongo',
type: 'boolean',
name: 'srv',
message: '+srv connection::',
message: '+srv connection:',
default: _.get(scope.database, 'srv', false)
},
{
when: !hasDatabaseConfig,
type: 'input',
name: 'port',
message: 'Port(It will be ignored if you enable +srv):',
message: 'Port (It will be ignored if you enable +srv):',
default: (answers) => { // eslint-disable-line no-unused-vars
if (_.get(scope.database, 'port')) {
return scope.database.port;
@ -259,7 +259,7 @@ module.exports = (scope, cb) => {
require(path.join(`${scope.tmpPath}`, '/node_modules/', `${scope.client.connector}/lib/utils/connectivity.js`))(scope, cb.success, connectionValidation);
} catch(err) {
shell.rm('-r', scope.tmpPath);
console.log(err)
console.log(err);
cb.success();
}
});

View File

@ -28,7 +28,7 @@ module.exports = (scope, success, error) => {
connectOptions.useNewUrlParser = true;
connectOptions.dbName = scope.database.settings.database;
Mongoose.connect(`mongodb${srv ? "+srv" : ""}://${scope.database.settings.host}:${!srv ? ":" + scope.database.settings.port : ""}/`, connectOptions, function (err) {
Mongoose.connect(`mongodb${srv ? '+srv' : ''}://${scope.database.settings.host}${!srv ? `:${scope.database.settings.port}` : ''}/`, connectOptions, function (err) {
if (err) {
console.log('⚠️ Database connection has failed! Make sure your database is running.');
return error();