mongodb - How to query nested objects? -


i have problem when querying mongodb nested objects notation:

db.messages.find( { headers : { from: "reservations@marriott.com" } } ).count() 0 db.messages.find( { 'headers.from': "reservations@marriott.com" }  ).count() 5 

i can't see doing wrong. expecting nested object notation return same result dot notation query. wrong?

db.messages.find( { headers : { from: "reservations@marriott.com" } } )

this queries documents headers equals { from: ... }, i.e. contains no other fields.


db.messages.find( { 'headers.from': "reservations@marriott.com" } )

this looks @ headers.from field, not affected other fields contained in, or missing from, headers.


dot-notation docs


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -