mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 08:04:51 +00:00
Merge branch 'master' into fix-build-assets-link
This commit is contained in:
commit
4d0083a4b6
@ -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;
|
||||
}
|
||||
|
||||
@ -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];
|
||||
|
||||
|
||||
@ -383,6 +383,7 @@ class Strapi extends EventEmitter {
|
||||
{
|
||||
orm: connector,
|
||||
primaryKey: Model.primaryKey,
|
||||
associations: Model.associations
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user