【问题标题】:How do I ask mongo for all the embedded documents that match my criteria?如何向 mongo 询问符合我的标准的所有嵌入文档?
【发布时间】:2017-07-08 15:37:58
【问题描述】:

我有一个电影集合,并且该电影集合有一个嵌入的评论文档数组。我想选择所有 status=1 的评论

{
  reviews: [
    {
      status: 0,
      text: 'hello'
    }, {
      status: 1,
      text: 'hi'
    }
}, {
    ... etc ...

【问题讨论】:

    标签: mongodb nosql


    【解决方案1】:

    同样的问题有答案:Filtering embedded documents in MongoDB

    在当前稳定版本的 mongodb 中,仍然无法进行嵌入式文档过滤。

    在 2.1.0 中有聚合。您可以使用unwindmatch 过滤评论

    不过我自己没试过。

    【讨论】:

      猜你喜欢
      • 2011-08-18
      • 2015-12-21
      • 2021-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多