Mongo用户的最后评论集合

时间:2019-01-07 16:11:07

标签: mongodb collections

让我们说我有很多用户

_id: ... name: 'the name'

和评论集

_id: ... comment: 'the comment' poster: user_id

然后使用单个查询从用户列表中获取最新评论?

1 个答案:

答案 0 :(得分:0)

在单个查询中使其唯一的方法是在$ lookup阶段运行聚合管道 https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/

相关问题