Merge branch 'master' into fix-build-assets-link

This commit is contained in:
Jim LAURIE 2018-06-06 14:43:57 +02:00 committed by GitHub
commit 4d0083a4b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -135,8 +135,8 @@ module.exports = {
toRemove.forEach(value => {
value = _.isString(value) ? { [this.primaryKey]: value } : value;
if (association.nature === 'manyToMany' && !_.isArray(params.values[this.primaryKey]) || params[this.primaryKey]) {
value[details.via] = value[details.via].filter(x => x.toString() !== params.values[this.primaryKey].toString());
if (association.nature === 'manyToMany' && !_.isArray(params.values[this.primaryKey] || params[this.primaryKey])) {
value[details.via] = value[details.via].filter(x => _.toString(x) !== _.toString(params.values[this.primaryKey] || params[this.primaryKey]));
} else {
value[details.via] = null;
}

View File

@ -131,10 +131,13 @@ module.exports = {
},
delete: async (params, { source }) => {
const response = await strapi.query(params.model, source).findOne({
const query = strapi.query(params.model, source);
const primaryKey = query.primaryKey;
const response = await query.findOne({
id: params.id
});
params[primaryKey] = response[primaryKey];
params.values = Object.keys(JSON.parse(JSON.stringify(response))).reduce((acc, current) => {
const association = (strapi.models[params.model] || strapi.plugins[source].models[params.model]).associations.filter(x => x.alias === current)[0];

View File

@ -383,6 +383,7 @@ class Strapi extends EventEmitter {
{
orm: connector,
primaryKey: Model.primaryKey,
associations: Model.associations
},
);