Let's say I have the following documents
Article { Comment: embedMany }
Comment { Reply: embedMany }
Reply { email: string, ip: string }
I want to make a query that selects distinct Reply.ip
where Reply.email = xxx
Something like this, only it doesn't work..
db.Article.find("Comment.Reply.email" : "xxx").distinct("Comment.Reply.ip")
JSON export:
{
"_id":{
"$oid":"4e71be36c6eed629c61cea2c"
},
"name":"test",
"Comment":[
{
"name":"comment test",
"Reply":[
{
"ip":"192.168.2.1",
"email":"yyy"
},
{
"ip":"127.0.0.1",
"email":"zzz"
}
]
},
{
"name":"comment 2 test",
"Reply":[
{
"ip":"128.168.1.1",
"email":"xxx"
},
{
"ip":"192.168.1.1",
"email":"xxx"
}
]
}
]
}
I run : db.Article.distinct("Comment.Reply.ip",{"Comment.Reply.email" : "xxx"})
I expect : ["128.168.1.1", "192.168.1.1"]
I get : ["127.0.0.1", "128.168.1.1", "192.168.1.1", "192.168.2.1"]