0
我有一個集合名稱dbapp在我的mongodb中。有一個文件如下,我想刪除的控件對象裏面widgets.I很困擾,爲您that.Apprciate help.thanks在集合中刪除對象數組中的對象mongo db
db.dbapp.insert(
{
"tenantid": 16,
"id": 0,
"default": true,
"widgets": [
{
"_id": new ObjectId(),
"position": 1,
"type": 1,
"class": "green",
"metricid": 5
},
{
"_id": new ObjectId(),
"position": 2,
"type": 1,
"class": "blue",
"metricid": 6
},
{
"_id": new ObjectId(),
"position": 3,
"type": 2,
"class": "normal",
"metricid": 1
},
{
"_id": new ObjectId(),
"position": 4,
"type": 2,
"class": "normal",
"metricid": 2
},
{
"_id": new ObjectId(),
"position": 5,
"type": 2,
"class": "normal",
"metricid": 3
}
],
"settings": {
"appid": 0,
"appname": "default"
}
});
你嘗試過這麼遠嗎?看看位置運算符$和$ pull方法。請參閱 - http://stackoverflow.com/documentation/mongodb/1683/crud-operation/22368/update-of-embedded-documents#t=201705171111210941696 –