Is it possible to query for specific objects within a nested document? Heres an example,
Collection : Threads
{
Documents : Messages
{
threadId = 1
messages = [
{
user = amy
date = 01/01/2012
content = hey
},
{
user = bell
date = 01/01/2012
content = hey
},
{
user = bell
date = 01/02/2012
content = whats up
}
]
},
{
threadId = 2
messages = [
{
user = courtney
date = 01/03/2012
content = first!
}
]
}
}
I would like my query to say { threadId : 1, 'messages.date' : { $gt : 01/01/2012 } }, { fields : { messages : 1 } }
. But it will return all of that documents messages when really all i want as a result is this,
messages = [
{
user = bell
date = 01/02/2012
content = whats up
}
]
You cannot return just the selected subdocument. You'll get all of them. So you'll have to filter on the client side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With