How can I remove array item from the collection2 collection?


Spent hours trying to make it working:

x.update({ _id: xID }, { $pull: { history: { historyID: givenhistoryID } } });

where history is an array inside collection, and historyID is a

Have no luck, still getting infamous “After filtering out keys not in the schema, your modifier is now empty”.

It it possible to remove array item from SimpleSchemed collection2 ???

Same problem as:


No experience with this issue. A workaround might be to fetch the record first, then use lodash to filter out the item from the array and then use $set to update the entire array. This is one of the reasons why I try to avoid 'subarrays at all cost in MongoDB.


It was my fault finally. I missed some schema structure information as well as field name :slight_smile:

it’s working like this:

x.update({ _id: xID }, { $pull: { YYY.history: { historyId: givenhistoryID } } });

array was one level deeper and index field name was 'historyIdnothistoryID`.