用猫鼬删除arr字段中的对象

时间:2018-08-14 15:28:35

标签: javascript arrays mongodb mongoose

如何在文档的朋友数组中删除对象ID为“ 5b718d1ff621ea09dcc27531”的id为“ 5b715caefe301a473c945aea”的对象?

{
    "_id" : ObjectId("5b718d1ff621ea09dcc27531"),
    "friends" : [ 
        {
            "_id" : "5b715caefe301a473c945aea",
            "another stuff": 234
        }, 
        {
            "_id" : "5b6ef34cf2b0c73490d9f742",
            "another stuff": 234
        }
    ],
},
{
    "_id" : ObjectId("5b718d1ff621ea09dcc27531"),
    "friends" : [ 
        {
            "_id" : "5b715caefe301a473c945aea",
            "another stuff": 234
        }, 
        {
            "_id" : "5b6ef34cf2b0c73490d9f778",
            "another stuff": 234
        }
    ],
}

0 个答案:

没有答案