Reputation: 251
{
_id: "joe",
name: "Joe Bookreader",
addresses: [
{
street: "123 Fake Street",
city: "Faketon",
state: "MA",
zip: "12345"
},
{
street: "1 Some Other Street",
city: "Boston",
state: "MA",
zip: "12345"
}
]
}
How to find the key street if it exists in this document?
Upvotes: 1
Views: 1844
Reputation: 2954
You can use $exists operator:
db.yourCollectionName.find( { 'addresses.street': { $exists: true } } );
Upvotes: 4