I want to find all documents whose _id exist in idUpdates , and then in those documents, there is an array named closedBy. This array contains objects of the following type:
{
position: ObjectID,
amount: Number
}
I then need to remove those objects who have position equal to a certain value (foundPosition._id).
I have tried the following but it does not work:
await Position.updateMany(
{ _id: { $in: idUpdates } },
{ $pull: { closedBy: { position: foundPosition._id } } }
);