Merge items of multiple arrays into a single array

I have an object field that has multiple arrays. I want to get a single array field that has all items combined from the multiple arrays in the object field. Which aggregation stage and operator can I use to achieve this.

image
This is how the document structure is where fieldN is in object field which has multiple arrays

image

This is what I would like to achieve where fieldN is an array field which contains all items combined from the multiple arrays from before into a single array.

Any help on this would really be appreciated!!

Hi Pratika,

You can achieve this using $reduce operator.
Here is the sample code.

2 Likes