mirror of
https://github.com/strapi/strapi.git
synced 2025-08-08 00:37:38 +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,
|
when: !hasDatabaseConfig,
|
||||||
type: 'input',
|
type: 'input',
|
||||||
name: 'port',
|
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
|
default: (answers) => { // eslint-disable-line no-unused-vars
|
||||||
if (_.get(scope.database, 'port')) {
|
if (_.get(scope.database, 'port')) {
|
||||||
return scope.database.port;
|
return scope.database.port;
|
||||||
@ -203,7 +203,7 @@ module.exports = (scope, cb) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope.database.settings.host = answers.host;
|
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.port = answers.port;
|
||||||
scope.database.settings.database = answers.database;
|
scope.database.settings.database = answers.database;
|
||||||
scope.database.settings.username = answers.username;
|
scope.database.settings.username = answers.username;
|
||||||
|
@ -51,9 +51,10 @@ module.exports = function (strapi) {
|
|||||||
initialize: cb => {
|
initialize: cb => {
|
||||||
_.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-hook-mongoose'}), (connection, connectionName) => {
|
_.forEach(_.pickBy(strapi.config.connections, {connector: 'strapi-hook-mongoose'}), (connection, connectionName) => {
|
||||||
const instance = new Mongoose();
|
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 uriOptions = uri ? url.parse(uri, true).query : {};
|
||||||
const { authenticationDatabase, ssl, debug } = _.defaults(connection.options, uriOptions, strapi.config.hook.settings.mongoose);
|
const { authenticationDatabase, ssl, debug } = _.defaults(connection.options, uriOptions, strapi.config.hook.settings.mongoose);
|
||||||
|
const isSrv = srv === true || srv === 'true';
|
||||||
|
|
||||||
// Connect to mongo database
|
// Connect to mongo database
|
||||||
const connectOptions = {};
|
const connectOptions = {};
|
||||||
@ -73,10 +74,16 @@ module.exports = function (strapi) {
|
|||||||
|
|
||||||
connectOptions.ssl = ssl === true || ssl === 'true';
|
connectOptions.ssl = ssl === true || ssl === 'true';
|
||||||
connectOptions.useNewUrlParser = true;
|
connectOptions.useNewUrlParser = true;
|
||||||
|
connectOptions.dbName = database;
|
||||||
|
|
||||||
options.debug = debug === true || debug === 'true';
|
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) {
|
for (let key in options) {
|
||||||
instance.set(key, options[key]);
|
instance.set(key, options[key]);
|
||||||
|
@ -926,7 +926,10 @@
|
|||||||
},
|
},
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": ""
|
"value": "",
|
||||||
|
"validations": {
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": {
|
"label": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user