DEV Community

Nagarajan R
Nagarajan R

Posted on

Answer: MongoDB nested lookup with 3 levels

The cause of your 'troubles' is the second aggregation stage - { $unwind: "$address" }. It removes record for party with _id: 4 (because its address array is empty, as you mention) and produces two records for parties _id: 1 and _id: 5 (because each of them has twoโ€ฆ

Top comments (1)

Collapse
 
dimer191996 profile image
Dimer Bwimba • Edited