Count for Nested array objects

Hi,

I was wondering if there's a way return count based on nested array items, instead of Document count.

e.g:

So if I have something like this:

obj : {
array : [{
id: 1,
group: A
},
{
id: 2,
group: A
},
{
id: 3,
group: B
}]
}

And I want to count number of items with group=A, it should return 2, instead of 1 (the Doc count)

Is there a way of doing this?

Thanks

1 Like