我有一个项目,我使用mongodb作为数据库。所以我想以下
例如,有一个产品集合
products: [
{
"name": "Product 1",
"products": [
{
"file": "data:image/;base64,",
"name": "Sacs bordeaux",
"description": "Pour les crémations Référence",
"id": 13,
"path": ""
},
{
"file": "data:image/;base64,",
"name": "Sacs bordeaux",
"description": "Pour les crémations Référence",
"id": 11,
"path": ""
},
{
"file": "data:image/;base64,",
"name": "Sacs bordeaux",
"description": "Pour les crémations Référence",
"id": 10,
"path": ""
}
]
},
{
"name": "Product 2",
"products": [
{
"file": "data:image/;base64,",
"name": "Sacs bordeaux",
"description": "Pour les crémations Référence",
"id": 10,
"path": ""
},
{
"file": "data:image/;base64,",
"name": "Sacs bordeaux",
"description": "Pour les crémations Référence",
"id": 11,
"path": ""
}
]
}
]
我想删除ID为:10从所有的文档集合产品中使用updatesmany或任何MongoDB查询所以在更新之后,最终的文档应该是这样的
products: [
{
"name": "Matériel crémation",
"products": [
{
"file": "data:image/;base64,",
"name": "Sacs bordeaux",
"description": "Pour les crémations Référence",
"id": 13,
"path": ""
},
{
"file": "data:image/;base64,",
"name": "Sacs bordeaux",
"description": "Pour les crémations Référence",
"id": 11,
"path": ""
}
]
},
{
"name": "Documents",
"products": [
{
"file": "data:image/;base64,",
"name": "Sacs bordeaux",
"description": "Pour les crémations Référence",
"id": 11,
"path": ""
}
]
}
]
1条答案
按热度按时间wlzqhblo1#
将
$filter
与$set
连接起来这里是Mongo Playground供您参考。