mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
use entity id when deleting components
This commit is contained in:
parent
d5ae2f97a9
commit
38ed957224
@ -214,14 +214,10 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const componentsToDelete = await getComponents(uid, entityToDelete).then((x) =>
|
const componentsToDelete = await getComponents(uid, entityToDelete);
|
||||||
_.omitBy(_.isNill, x)
|
|
||||||
);
|
|
||||||
|
|
||||||
await db.query(uid).delete({ where: { id: entityToDelete.id } });
|
await db.query(uid).delete({ where: { id: entityToDelete.id } });
|
||||||
if (!_.isEmpty(componentsToDelete)) {
|
await deleteComponents(uid, componentsToDelete);
|
||||||
await deleteComponents(uid, { ...entityToDelete, ...componentsToDelete });
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.emitEvent(uid, ENTRY_DELETE, entityToDelete);
|
await this.emitEvent(uid, ENTRY_DELETE, entityToDelete);
|
||||||
|
|
||||||
@ -242,9 +238,7 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|||||||
}
|
}
|
||||||
|
|
||||||
const componentsToDelete = await Promise.all(
|
const componentsToDelete = await Promise.all(
|
||||||
entitiesToDelete.map((entityToDelete) =>
|
entitiesToDelete.map((entityToDelete) => getComponents(uid, entityToDelete))
|
||||||
getComponents(uid, entityToDelete).then((x) => _.omitBy(_.isNill, x))
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const deletedEntities = await db.query(uid).deleteMany(query);
|
const deletedEntities = await db.query(uid).deleteMany(query);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user