mirror of
https://github.com/strapi/strapi.git
synced 2025-08-07 16:29:18 +00:00
Merge branch 'master' into fix/repeat-upload-the-same-file
This commit is contained in:
commit
b43f28e611
@ -152,7 +152,7 @@ module.exports = (scope, cb) => {
|
||||
when: !hasDatabaseConfig,
|
||||
type: 'input',
|
||||
name: 'port',
|
||||
message: 'Port (It will be ignored if you enable +srv):',
|
||||
message: `Port${scope.client.database === 'mongo' ? ' (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;
|
||||
@ -203,7 +203,7 @@ module.exports = (scope, cb) => {
|
||||
}
|
||||
|
||||
scope.database.settings.host = answers.host;
|
||||
scope.database.settings.srv = answers.srv;
|
||||
scope.database.settings.srv = _.toString(answers.srv) === 'true';
|
||||
scope.database.settings.port = answers.port;
|
||||
scope.database.settings.database = answers.database;
|
||||
scope.database.settings.username = answers.username;
|
||||
|
@ -51,9 +51,10 @@ module.exports = function (strapi) {
|
||||
initialize: cb => {
|
||||
_.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-hook-mongoose'}), (connection, connectionName) => {
|
||||
const instance = new Mongoose();
|
||||
const { uri, host, port, username, password, database } = _.defaults(connection.settings, strapi.config.hook.settings.mongoose);
|
||||
const { uri, host, port, username, password, database, srv } = _.defaults(connection.settings, strapi.config.hook.settings.mongoose);
|
||||
const uriOptions = uri ? url.parse(uri, true).query : {};
|
||||
const { authenticationDatabase, ssl, debug } = _.defaults(connection.options, uriOptions, strapi.config.hook.settings.mongoose);
|
||||
const isSrv = srv === true || srv === 'true';
|
||||
|
||||
// Connect to mongo database
|
||||
const connectOptions = {};
|
||||
@ -73,10 +74,16 @@ module.exports = function (strapi) {
|
||||
|
||||
connectOptions.ssl = ssl === true || ssl === 'true';
|
||||
connectOptions.useNewUrlParser = true;
|
||||
connectOptions.dbName = database;
|
||||
|
||||
options.debug = debug === true || debug === 'true';
|
||||
|
||||
instance.connect(uri || `mongodb://${host}:${port}/${database}`, connectOptions);
|
||||
/* FIXME: for now, mongoose doesn't support srv auth except the way including user/pass in URI.
|
||||
* https://github.com/Automattic/mongoose/issues/6881 */
|
||||
instance.connect(uri ||
|
||||
`mongodb${isSrv ? '+srv' : ''}://${username}:${password}@${host}${ !isSrv ? ':' + port : '' }/`,
|
||||
connectOptions
|
||||
);
|
||||
|
||||
for (let key in options) {
|
||||
instance.set(key, options[key]);
|
||||
|
@ -926,7 +926,10 @@
|
||||
},
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
"value": "",
|
||||
"validations": {
|
||||
"required": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user