这是我的第一个网络应用程序,我需要删除一个嵌套的数组项。如何使用此模式在Mongoose中删除对象:
User: {
event: [{_id:12345, title: "this"},{_id:12346, title:"that"}]
}
我该如何在mongoose/Mongo中删除id:12346
?
event { _id: 123456)
并将其删除,对吗?如果需要,我可以通过在第一个条件中放置一个ID来仅删除一个实例,对吗? - illcrx$pull
will delete specific value/values in an existing array and not the whole document that matches the condition. If you want to delete the whole document that matches the condition, usedb.collection.remove
- Supradeep