I have the following model...
{
username: 'bob',
data: [
{
sport: 'football',
events: [
{
event: 1,
_id: 'h4jh234ht34j'
},
{
event: 2,
_id: '4h326ol2j3ld'
},
{
event: 2,
_id: 'fdsfasdfa3ws'
}
// ... more events
]
},
{
sport: 'cricket',
events: [
{
event: 3,
_id: 'hd2g234ht3gj'
},
{
event: 2,
_id: '33326oldwqld'
},
{
event: 6,
_id: '461fa24gsa3s'
}
// ... more events
]
},
// ... more sports
]
}
Is there a way I can query this database to find any event objects where the event property equals 2? I want the query to return an array of objects for all the events from the different collections where the event = 2. Is this possible, or does the events array need to be an immediate ancestor of the "data" property?