【问题标题】:Mongo last comment collection of usersMongo用户最后评论合集
【发布时间】:2019-01-07 16:11:06
【问题描述】:

假设我有一组用户

_id: ... name: 'the name'

还有一组cmets

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

然后使用单个查询从用户列表中获取最后一个 cmets?

【问题讨论】:

  • 你能发布样本集吗

标签: mongodb collections


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 1970-01-01
    相关资源
    最近更新 更多