I have a collection in Mongo that contains documents that look like this:
{
name: "Bob",
destinations:
[
{
city: "Dallas",
state: "Texas",
isBusiness: "true",
}, {
city: "San Diego",
state: "California",
isBusiness: "true",
}
]
},
{
name: "Sue",
destinations:
[
{
city: "Las Vegas",
state: "Nevada",
isBusiness: "false",
}, {
city: "Sacramento",
state: "California",
isBusiness: "true",
}
]
}
I want to query this collection so that I receive the name of each person along with the city of each destination within the state of California, but not the isBusiness value which should be ignored.
The result of the query should be:
[
{
name: "Bob",
city: "San Diago",
},
{
name: "Sue",
city: "Sacramento"
}
]
This example is a bit contrived, but how do I do this?