要处理的数据格式
{
"_id" : ObjectId("607eb43fc6d1f58d655e11f8"),
"origin_area_code" : "530102",
"origin_area_name" : "五华区",
"sources" : [
{
"source" : "langchao",
"syncFlag" : true,
"shareId" : "8244045083a44851bcff7517bec650b7"
},
{
"source" : "dehong",
"syncFlag" : false,
"shareId" : "WC26wvNb"
},
{
"source" : "langchao",
"syncFlag" : false,
"shareId" : "7341755350364e7db708184d3777640f"
}
]
}
mongoDb 数组嵌套查询语句写法:
shareId不存在的所有数据:db.getCollection("nat_checked_person").find({"sources":{ $elemMatch: { "source": "dehong", "shareId": {$exists: false}} }})
shareId=WC26wvNb的所有数据:
db.getCollection("nat_checked_person").find({"sources":{ $elemMatch: { "source": "dehong", "shareId": "WC26wvNb"} }})