MongoDB remove an item from an array inside an array of objects

与世无争的帅哥 提交于 2019-12-01 03:56:00

You need to use the positional $ update operator to remove the element from your array. You need this is because "sections" is an array of sub-documents.

db.test.findOneAndUpdate(
    { "sections._id" : ObjectId("56fea43a571332cc97e06d9e") }, 
    { "$pull": { "sections.$.registered": "e3d65a4e-2552-4995-ac5a-3c5180258d87" } } 
)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!