2 / 2
Jul 2024

Consider the following example dataset:

[ { "slots": [ { "rewards": [ { "id": 0001, "icon": "foo.jpg" } ] }, { "rewards": [ { "id": 0002, "icon": "bar.jpg" }, { "id": 0003, "icon": null } ] } ] } ]

Now I want to figure out all reward element with id but without icon, and turning them into a unique array.

I’ve already tried $concatArray and $unwind, but failed to flatten the nested array.