I want to pull (remove) an ObjectId from an array in a Mongoose document, but it isn't removed. The code is like this
UserModel.updateOne({ _id: author._id }, {
$pull:
{ snippets: { _id: ObjectId(snippet._id) } }
})
The author._id is the ID of the particular user of the UserModel. snippets is an array of ObjectId's referring to another schema. snippet is the document whose ObjectId I want to remove from the array.
I think I have made it clear what I want, but the ObjectId is not removed from the array, which I can see in the database.