I have the following situation in my aggregation: At some point my documents are holding an array of objects and an array of the same length at the root level. An example would be:
{_id:0,
cars:[{name:"vw polo",door:3},{name:"vw golf",door:5}],
possible_colors:[["black","blue"],["white"]]}
What I'm trying now is to update project the possible colors into each object of the cars array. The expected result should look as follows.
{_id:0,
cars:[{name:"vw polo",door:3,possible_colors:["black","blue"]},
{name:"vw golf",door:5,possible_colors:["white"]}],
}
I already tried {$addfields:{cars:{$zip:[$cars,$possible_colors]}}}, but this creates a list of arrays, where each array contains the object and the correct subarray, but i was not able to merge them.