I am trying to query a mongodb document without luck. The following query works to get a user whose id is domainOwner and scope is clearcrimson.
db.getCollection("users").findOne( { "roles": { $elemMatch: {_id: "domainOwner", scope: "clearcrimson" } } }, {_id:1})
How can I modify the query to get a user whose one email id could be a@b.com, id is domainOwner and scope is clearcrimson?
Document:
{
"_id" : "7Rc5q2o3Qnv7j2HuT",
"emails" : [
{"address" : "a@b.com"},
{"address" : "c@d.com"},
],
"roles" : [
{"_id" : "domainOwner", "scope" : "clearcrimson"},
{"_id" : "domainOwner", "scope" : "clearcrimson2"}
]
}