如何刪除嵌套的集合,例如下面,我想從Pic中刪除ID 50d3dbce1292dd2e98af1dd2?如何從嵌套集合中刪除數據?
數據:
{
"_id": "50d3dbce1292dd2e98af1dd1",
"Name": "Bubba",
"Address": "1111",
"Pic" : [{"_id": "50d3dbce1292dd2e98af1dd2", "Name": "test1.jpg", "Size":"1000"}, {"_id": "50d3dbce1292dd2e98af1dd3",. "Name": "test2.jpg", "Size":"2000"}],
"LastModified": {
"$date": "2012-12-21T03:47:26.535Z"
}
}
解決了$拉:
db.coll.update({},{$拉:{ '東西':{ '設爲myVal':1} }});
你試試這個? http://stackoverflow.com/questions/9048424/removing-specific-items-from-array-with-mongodb – WiredPrairie
剛剛嘗試過,它現在有效。 TQ。 – Alvin
爲了完整起見,您應該添加這個答案並接受它。 – mjhm