diff --git a/docs/3.x.x/en/configurations/configurations.md b/docs/3.x.x/en/configurations/configurations.md index ced94dd32b..01f3bcb751 100644 --- a/docs/3.x.x/en/configurations/configurations.md +++ b/docs/3.x.x/en/configurations/configurations.md @@ -1,6 +1,6 @@ # Configurations -The main configurations of the project are located in the `./config` directory. Additional configs can be added in the `./api/**/config` folder of each APIs and plugins by creating JavaScript or JSON files. +The main configurations of the project are located in the `./config` directory. Additional configs can be added in the `./api/**/config` folder of each API and plugin by creating JavaScript or JSON files. ## Application @@ -153,7 +153,7 @@ Each JSON file located in the folder must have the name of its corresponding tra Most of the application's configurations are defined by environment. It means that you can specify settings for each environment (`development`, `production`, `test`, etc.). -> Note: You can access to the config of the current environment through `strapi.config.currentEnvironment`. +> Note: You can access the config of the current environment through `strapi.config.currentEnvironment`. *** diff --git a/packages/strapi-hook-bookshelf/lib/relations.js b/packages/strapi-hook-bookshelf/lib/relations.js index 57ab4bf757..4b3083bad9 100644 --- a/packages/strapi-hook-bookshelf/lib/relations.js +++ b/packages/strapi-hook-bookshelf/lib/relations.js @@ -10,15 +10,17 @@ const _ = require('lodash'); // Utils const { models: { getValuePrimaryKey } } = require('strapi-utils'); -const transformToArrayID = (array) => { +const transformToArrayID = (array, association) => { if(_.isArray(array)) { - return array.map(value => { + array = array.map(value => { if (_.isPlainObject(value)) { - return value._id || value.id; + return value._id || value.id || false; } return value; }); + + return array.filter(n => n); } if (association.type === 'model' || (association.type === 'collection' && _.isObject(array))) { @@ -140,8 +142,8 @@ module.exports = { case 'manyToMany': if (response[current] && _.isArray(response[current]) && current !== 'id') { // Compare array of ID to find deleted files. - const currentValue = transformToArrayID(response[current]).map(id => id.toString()); - const storedValue = transformToArrayID(params.values[current]).map(id => id.toString()); + const currentValue = transformToArrayID(response[current], association).map(id => id.toString()); + const storedValue = transformToArrayID(params.values[current], association).map(id => id.toString()); const toAdd = _.difference(storedValue, currentValue); const toRemove = _.difference(currentValue, storedValue); @@ -229,8 +231,8 @@ module.exports = { case 'oneToManyMorph': case 'manyToManyMorph': { // Compare array of ID to find deleted files. - const currentValue = transformToArrayID(response[current]).map(id => id.toString()); - const storedValue = transformToArrayID(params.values[current]).map(id => id.toString()); + const currentValue = transformToArrayID(response[current], association).map(id => id.toString()); + const storedValue = transformToArrayID(params.values[current], association).map(id => id.toString()); const toAdd = _.difference(storedValue, currentValue); const toRemove = _.difference(currentValue, storedValue); diff --git a/packages/strapi-plugin-graphql/services/GraphQL.js b/packages/strapi-plugin-graphql/services/GraphQL.js index 254b776464..eb911fae2b 100644 --- a/packages/strapi-plugin-graphql/services/GraphQL.js +++ b/packages/strapi-plugin-graphql/services/GraphQL.js @@ -168,6 +168,9 @@ module.exports = { case 'float': type = 'Float'; break; + case 'json': + type = 'JSON'; + break; case 'time': case 'date': case 'datetime': diff --git a/packages/strapi-plugin-upload/services/Upload.js b/packages/strapi-plugin-upload/services/Upload.js index cef660041e..1b28422278 100644 --- a/packages/strapi-plugin-upload/services/Upload.js +++ b/packages/strapi-plugin-upload/services/Upload.js @@ -101,6 +101,8 @@ module.exports = { }, remove: async (params, config) => { + params.id = (params._id || params.id); + const file = await strapi.plugins['upload'].services.upload.fetch(params); // get upload provider settings to configure the provider to use @@ -116,7 +118,6 @@ module.exports = { // Use Content Manager business logic to handle relation. if (strapi.plugins['content-manager']) { params.model = 'file'; - params.id = (params._id || params.id); await strapi.plugins['content-manager'].services['contentmanager'].delete(params, {source: 'upload'}); }