Home > database >  Directing how to implement the first multi-table query on the basis of the second multi-table query?
Directing how to implement the first multi-table query on the basis of the second multi-table query?

Time:10-11

Project data query to projectMember

const res=await CTX. Model. Project
The aggregate ([
{
$match: {title},
},

{
$lookup: {
From: 'projectMember',
LocalField: '_id',
ForeignField: 'project_id',
As: 'members',
},
},
])


one more members field

/
{
"_id" : "5 eaab0716548c615306ed0fb,"
"Visible" : "public",
"Type" : "novel,"
"Title" : "the light man 2",
"Summary" : "loneliness has always been in, from beginning to end,",
"User_id" : "5 eaa88c44fe6dc2ef013b8b8,"
"Create_at" : "the 2020-04-30 T11:03:13. 861 z,"
"Update_at" : "the 2020-04-30 T11:03:13. 862 z,"
"__v" : 0,
"Members" : [
{
"_id" : "5 eaab07144a25541579fa966,"
"Project_id" : "5 eaab0716548c615306ed0fb,"
"User_id" : "5 eaa88c44fe6dc2ef013b8b8,"
"__v" : 0,
"Type" : "admin"
}
]
}
]


now, I want to, continue to multi-table query members of all the documents in the user_id associated User (table), could you tell me how to achieve?

CodePudding user response:

The members continue to lookup the foreignField want to members. User_id
  • Related