我想要实现的是获取alliance members
,然后我需要从alliance members
表中获取users
统计信息。到目前为止,这是我的代码:
Alliance.aggregate([
{
"$lookup": {
"from": "alliancemembers",
"localField": "_id",
"foreignField": "ally_id",
"as": "allymembers"
},
"$lookup": {
"from": "allymembers",
"localField": "_id",
"foreignField": "_id",
"as": "members"
}
}
所以在第一个lookup
中我得到了一个结盟成员,问题是我不知道如何写第二个lookup
来使用第一个{{1 }}并与allymembers
聚合(用户集合)