如果包含特定数据,如何编写Mongo查询以删除数组的元素?
{
"_id": ObjectId("ajdi293akjf83rhfsf398"),
"one": "oneData",
"two": [
{
"_id":ObjectId("akjf82ijikfj83jkfkj3"),
"value": 1
},
{
"_id":ObjectId("akjf82ijikfj83jkfkj3"),
"value": 2
},
{
"_id":ObjectId("akjf82ijikfj83jkfkj3"),
"value": 1
}
]
}
如果元素包含two
作为value
,则需要删除1
的元素
{
"_id": ObjectId("ajdi293akjf83rhfsf398"),
"one": "oneData",
"two": [
{
"_id":ObjectId("akjf82ijikfj83jkfkj3"),
"value": 2
}
]
}
请告诉我如何实现这一目标 非常感谢。