I have a document structure with arbitrarily nested arrays similar to follows, which I want to flatten during an aggregation pipeline:
{
"data": [
"one",
[
"two",
"three"
],
[
[ "four" ],
[ "five" ]
]
]
}
Expected result:
{ "data": [ "one", "two", "three", "four", "five" ] }
Existing question here gives some ideas (especially this answer), however not totally generically with an arbitrary depth of nesting.
Is there some more generic solution to this?