Project 查询到了 projectMember 的数据
const res = await ctx.model.Project
.aggregate([
{
$match: { title },
},
{
$lookup: {
from: 'projectMember',
localField: '_id',
foreignField: 'project_id',
as: 'members',
},
},
])
多了一个 members 字段
[
{
"_id": "5eaab0716548c615306ed0fb",
"visible": "公开",
"type": "小说",
"title": "守灯人2",
"summary": "孤独一直都在,从始至终。",
"user_id": "5eaa88c44fe6dc2ef013b8b8",
"create_at": "2020-04-30T11:03:13.861Z",
"update_at": "2020-04-30T11:03:13.862Z",
"__v": 0,
"members": [
{
"_id": "5eaab07144a25541579fa966",
"project_id": "5eaab0716548c615306ed0fb",
"user_id": "5eaa88c44fe6dc2ef013b8b8",
"__v": 0,
"type": "admin"
}
]
}
]
现在,我想要,继续多表查询 members 里所有文档的 user_id (关联 User 表),请问怎么实现?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…