[英]How to remove elements of an array based on the array element's data in MongoDB
How to write a Mongo query to remove elements of an array if it contain specific data? 如果包含特定数据,如何编写Mongo查询以删除数组的元素?
{
"_id": ObjectId("ajdi293akjf83rhfsf398"),
"one": "oneData",
"two": [
{
"_id":ObjectId("akjf82ijikfj83jkfkj3"),
"value": 1
},
{
"_id":ObjectId("akjf82ijikfj83jkfkj3"),
"value": 2
},
{
"_id":ObjectId("akjf82ijikfj83jkfkj3"),
"value": 1
}
]
}
Need to remove the elements of two
if the the elements contains value
as 1
如果元素包含的
value
1
则需要删除two
元素
{
"_id": ObjectId("ajdi293akjf83rhfsf398"),
"one": "oneData",
"two": [
{
"_id":ObjectId("akjf82ijikfj83jkfkj3"),
"value": 2
}
]
}
Please tell me how to achieve this Many Thanks in advance. 请提前告诉我如何实现此“非常感谢”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.