My scenario is explained below, but the application and data are just
an example.
{
_id : "1",
blog_name : "My First Blog",
entries : [
{
entry_id : "123",
entry_name : "My first entry",
posted : "2010-01-01",
comments : [ { user : "bob", comment : "cool"}, { user : "joe",
"not cool" } ]
},
{
entry_id : "124",
entry_name : "My second entry",
posted : "2010-01-01",
comments : [ { user : "jane", comment : "not cool"}, { user :
"sam", "not cool" } ]
},
{
entry_id : "125",
entry_name : "My third entry",
posted : "2010-01-02",
comments : [ { user : "jane", comment : "not cool"}, { user :
"sam", "not cool" } ]
}
]
}
db.blogs.find( { entries : { $elemMatch : { posted : "2010-01-01",
comments.comment : "cool" } } } )
This matches on entry 123 but entries 124 and 125 get returned also.
Is there a way to omit 124 and 125?
I really only want what matches. I realize that the entire entry in
the collection is being matched, but I
only want the subset that matches my query to be returned. I am hoping
my approach is wrong. The other
posts I have read are leading me to believe it is not possible.
Any ideas?
Would map reduce be appropriate for something like this? I understood
that mongo's implementation can
only handle returning numbers and simple objects. I would be returning
a blog entry with a nested array
of comments with the above scenario.
Thanks in advance for any help.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to
mongod...@googlegroups.com.
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/mongodb-user?hl=en.