Sunday 23 September 2018

Mongoose $pull

I have this "Todo" model which has an array called "notes" as one of its keys. This array contains objects (instances of Notes model). I am trying to delete from this array a specific "note" via its" _id", but it is not working. It works via text.​One Todo with one NoteI tried:var _id = req.params.id; //Todo _id Todo.findOneAndUpdate({_id}, {$pull: {notes: {"_id": "5ba7618e43cb2cbedb91e986"}}} ... but it isn't working... if I use {"text": "Some note"} it works... what am I missing?Thank you for you help - you're all amazing! :)

Submitted September 23, 2018 at 11:12AM by its_joao

No comments:

Post a Comment