在mongodb中删除arraylist的一个对象
Delete an object of array list in mongdb
我有一个集合,包含一个对象数组,我想通过此数组示例中的过滤器删除一个对象:
"ProductsImages" : [
{
"_id" : ObjectId("5c6fc524c324ac0e7497b6c0"),
"Namefile" : "Bild-4.png",
"Urls" : "https://fares.blob.core.windows.net/fares2/Bild-4.png"
},
{
"_id" : ObjectId("5c6fc52cc324ac0e7497b6c1"),
"Namefile" : "KINGSTON-BAY-704668-logo.png",
"Urls" : "https://fares.blob.core.windows.net/fares2/KINGSTON-BAY-704668-logo.png"
}
],
所以我想删除第一个包含 "Namefile" : "Bild-4.png" in mongodb shell 或 C# monogodb 驱动器的,感谢您的帮助。
请尝试此更新查询
db.collName.update({"ProductsImages.Namefile": "Bild-4.png"},{$pull: {"ProductsImages": {"Namefile": "Bild-4.png"}}})
Note: Update the first filter condition as required
我有一个集合,包含一个对象数组,我想通过此数组示例中的过滤器删除一个对象:
"ProductsImages" : [
{
"_id" : ObjectId("5c6fc524c324ac0e7497b6c0"),
"Namefile" : "Bild-4.png",
"Urls" : "https://fares.blob.core.windows.net/fares2/Bild-4.png"
},
{
"_id" : ObjectId("5c6fc52cc324ac0e7497b6c1"),
"Namefile" : "KINGSTON-BAY-704668-logo.png",
"Urls" : "https://fares.blob.core.windows.net/fares2/KINGSTON-BAY-704668-logo.png"
}
],
所以我想删除第一个包含 "Namefile" : "Bild-4.png" in mongodb shell 或 C# monogodb 驱动器的,感谢您的帮助。
请尝试此更新查询
db.collName.update({"ProductsImages.Namefile": "Bild-4.png"},{$pull: {"ProductsImages": {"Namefile": "Bild-4.png"}}})
Note: Update the first filter condition as required