I have such structure of document:
{
"_id" : "4e76fd1e927e1c9127d1d2e8",
"name" : "***",
"embedPhoneList" : [
{
"type" : "家庭",
"number" : "00000000000"
},
{
"type" : "手机",
"number" : "00000000000"
}
],
"embedAddrList" : [
{
"type" : "家庭",
"addr" : "山东省诸城市***"
},
{
"type" : "工作",
"addr" : "深圳市南山区***"
}
],
"embedEmailList" : [
{
"email" : "********@gmail.com"
},
{
"email" : "********@gmail.com"
},
{
"email" : "********@gmail.com"
},
{
"email" : "********@gmail.com"
}
]
}
What I wan’t to do is find the document by it’s sub document,such as email in embedEmailList field.
Or if I have structure like this
{
"_id" : "4e76fd1e927e1c9127d1d2e8",
"name" : "***",
"embedEmailList" : [
"123@gmail.com" ,
"********@gmail.com" ,
]
}
the embedEmailList is array,how to find if there is 123@gmail.com?
Thanks.
To search for a specific value in an array, mongodb supports this syntax:
See here for more information.
To search for a value in an embedded object, it supports this syntax:
See here for more information.