mongo 删除对象数组中的对象

{
    "_id" : ObjectId("5e782cb124c66a09547823a2"),
    "goods" : [ 
        {
            "isChecked" : false,
            "_id" : ObjectId("5e782cb124c66a09547823a3"),
            "goodId" : "211",
            "goodCount" : 999
        }, 
        {
            "isChecked" : false,
            "_id" : ObjectId("5e782e00dd08281aeca3da31"),
            "goodId" : "212",
            "goodCount" : 888
        }
    ],
    "userId" : "111",
    "__v" : 0
}
db.carts.update({'userId':'111'},{$pull:{'goods':{'goodId':'212'}}})

你可能感兴趣的:(mongo 删除对象数组中的对象)