You can use $exists operator:
db.yourCollectionName.find( { 'addresses.street': { $exists: true } } );
Question
{
_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?
Solution
You can use $exists operator:
db.yourCollectionName.find( { 'addresses.street': { $exists: true } } );