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
.
Comments
Post a Comment