Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

finding by sub property of an object in mongo

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

This queries for documents where headers equals { From: ... }, i.e. contains no other fields.

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

This only looks at the headers.From field, not affected by other fields contained in, or missing from, headers.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #finding #property #object #mongo
ADD COMMENT
Topic
Name
1+4 =