I have array of nested objects in my MongoDB schema. Lets say,
var Post = {
"title": "Some title",
"advertisers" : [
{
"category" : "Tech",
"name" : "Henry",
"city" : "New york",
"updated_at" : ISODate("2011-07-26T21:02:19Z"),
"created_at" : ISODate("2011-07-26T21:02:19Z")
},
]
}
I want to find the post based on the multiple values in nested schema. eg
Post.find({ 'advertisers.category' : 'Tech', 'advertisers.city': 'New York' });
It returns post which matches one of the above criteria. But i want posts which matches both.
How can i do it?