Fix deep delete relation for oneWay and when there is no relations

This commit is contained in:
Jim LAURIE 2018-10-08 12:25:44 +02:00
parent ebd60f93cc
commit d586442fbd

View File

@ -129,6 +129,10 @@ module.exports = {
await Promise.all(
<%= globalID %>.associations.map(async association => {
if (!association.via || !data._id) {
return true;
}
const search = _.endsWith(association.nature, 'One') || association.nature === 'oneToMany' ? { [association.via]: data._id } : { [association.via]: { $in: [data._id] } };
const update = _.endsWith(association.nature, 'One') || association.nature === 'oneToMany' ? { [association.via]: null } : { $pull: { [association.via]: data._id } };