How to query nested objects?

I have a problem when querying mongoDB with nested objects notation:

db.messages.find( { headers : { From: "[email protected]" } } ).count()
0
db.messages.find( { 'headers.From': "[email protected]" }  ).count()
5

I can’t see what I am doing wrong. I am expecting nested object notation to return the same result as the dot notation query. Where am I wrong?

3 Answers
3

Leave a Comment