Skip to content

Commit

Permalink
fix: aligend with Pretiier
Browse files Browse the repository at this point in the history
  • Loading branch information
scientiststwin committed Jan 26, 2024
1 parent e8d1c6e commit c1c6839
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/models/schemas/Platform.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,37 @@ platformSchema.plugin(toJSON);
platformSchema.plugin(paginate);

const announcementDeletion = async (platformId: any): Promise<void> => {
// ?in case the platformID (inputted platformID) of each item in the data array field matches, delete that announcement.
const announcementsWithAllDataOnSamePlatformIds = await Announcement.aggregate([
// ?in case the platformID (inputted platformID) of each item in the data array field matches, delete that announcement.
const announcementsWithAllDataOnSamePlatformIds = await Announcement.aggregate([
{
$match: {
"data.platform": platformId,
}
'data.platform': platformId,
},
},
{
$project: {
allMatch: {
$not: [
{
$elemMatch: {
"data.platform": { $ne: platformId }
}
}
]
}
}
'data.platform': { $ne: platformId },
},
},
],
},
},
},
{
$match: {
allMatch: true
}
}
])
const idsToDelete = announcementsWithAllDataOnSamePlatformIds.map(announcement => announcement._id)
await Announcement.deleteMany({ _id: { $in: idsToDelete } })
allMatch: true,
},
},
]);
const idsToDelete = announcementsWithAllDataOnSamePlatformIds.map((announcement) => announcement._id);
await Announcement.deleteMany({ _id: { $in: idsToDelete } });

await Announcement.updateMany({ 'data.platform': platformId }, { $pull: { data: { platform: platformId } } });
}
};

platformSchema.pre('remove', async function (this: Document) {
const platformId = this._id;
Expand Down

0 comments on commit c1c6839

Please sign in to comment.