Database

db={"servicesByAffiliate":[{"_id":ObjectId("5d4fb125ec8bb5af826935f1"),"category":ObjectId("5d4fb125ec8bb5af826935f1"),"service":ObjectId("5ce520370fc47e2d0edc4411")}],"categories":[{"_id":ObjectId("5d4fb125ec8bb5af826935f1"),"active":true,"enabled":false,"name":{"en":"General Medicine","other":"xxx"},"description":{"en":"Is a General Medicine","other":"xxx"},"parentCategory":[ObjectId("5dd095d860c43279e76e8d06")]},{"_id":ObjectId("5dd095d860c43279e76e8d06"),"name":{"en":"Parent Category","other":"xxx"}}],"services":[{"_id":ObjectId("5ce520370fc47e2d0edc4411"),"active":true,"enabled":true,"affiliateType":["5d242feb3555ec2b76e86bce"],"name":{"en":"Laboratory Tests","other":"xxx"},"description":{"en":"Laboratory Tesrs","es":"xxx"},"createdAt":"2019-05-22T10:11:03.945Z","updatedAt":"2019-12-30T21:55:03.569Z","__v":0,"isAppointment":false,"atHome":true}]}

Query

db.servicesByAffiliate.aggregate([{$lookup:{from:"services",localField:"service",foreignField:"_id",as:"service"}},{$lookup:{from:"categories",localField:"category",foreignField:"_id",as:"category",}},{$addFields:{service:{$first:"$service"},category:{$first:"$category"}}},{$lookup:{from:"categories",localField:"category.parentCategory",foreignField:"_id",as:"category.parentCategory"}}])

Result