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 –