Answer the question
In order to leave comments, you need to log in
What is the correct way to use the aggregate function to combine data from multiple collections?
Hello.
There are several collections
Users
Team members (where there is a link to a user)
Team messages (where there is a link to a team member)
how to properly build a pipeline to collect related data on a user
Пользователь
- члены команд
- сообщения команд
db['users'].aggregate([
{"$match":{"chat_id":user.chat_id}},
{"$lookup":{
"localField" : "_id",
"from" : "team_members",
"foreignField" : "user_id",
"as":"member"
}}])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question