Skip to content
Advertisement

MongoDB : fields are excluded when invoke multiple lookup stages

JavaScript

JavaScript

Result :

JavaScript

[![enter image description here][1]][1]

Why the fields name and region in collection templatefolders are excluded ? I want to know why this behavior ? I don’t like to use unwind because i have multiple collections with multiple refrence relation.

Advertisement

Answer

Your second $lookup, is overriding the joinDashboard key completely. Since you want joinFolder to be within joinDashboard, you can try nested lookups like this:

JavaScript

MongoPlayground link.

Advertisement