I have an aggregation query producing an array containing array elements. How can I $sum the values and produce output similar to the following:
{ "additionalReminders": 7 }
This is an example of the data structure. Notice some of the array elements are empty and should be ignored or counted as 0:
{
"additionalReminders": [
[
"1",
"1"
],
[],
[],
[
"1"
],
[],
[
"1"
],
[],
[
"1"
],
[],
[
"1"
],
[],
[],
[
"1"
]
]
}
Mongo Playground: https://mongoplayground.net/p/BjSU_oYC8KG