Database
[{"collection":"company","count":10,"content":{"title":{"type":"faker","method":"Company"},"_id":{"type":"ref","id":1,"refContent":{"type":"objectId"}}}},{"collection":"plans","count":10,"content":{"title":{"type":"faker","method":"EmojiDescription"},"companyId":{"type":"ref","id":1},"_id":{"type":"ref","id":2,"refContent":{"type":"objectId"}}}},{"collection":"promotions","count":10,"content":{"title":{"type":"faker","method":"BeerStyle"},"planId":{"type":"ref","id":2}}}]
Query
db.company.aggregate([{/** lookup plans matching companies*/"$lookup":{"from":"plans","localField":"_id","foreignField":"companyId","pipeline":[{/** lookup promotions matching plans*/"$lookup":{"from":"promotions","localField":"_id","foreignField":"planId","as":"promotions"}}],"as":"plans"}},{/** drop unwanted fields*/"$project":{"_id":0,"plans._id":0,"plans.companyId":0,"plans.promotions._id":0,"plans.promotions.planId":0}}])