How to join query in mongodb?

To have everything with just one query using the $lookup feature of the aggregation framework, try this : db.User.aggregate( [ // First step is to extract the “friends” field to work with the values { $unwind: “$friends” }, // Lookup all the linked friends from the User collection { $lookup: { from: “User”, localField: “friends”, … Read more