【问题标题】:robo 3t - Aggregate query on array failsrobo 3t - 对阵列的聚合查询失败
【发布时间】:2019-04-05 12:44:02
【问题描述】:

设置: 父集合中的文档有一个带有子标识符的子字段。子集合中的文档在 customId 字段中具有标识符,而不是 _id。 'children' 字段中的单个标识符可能匹配多个子项。

怎么了: 这个查询

db.getCollection('parent').aggregate({$lookup: {from: "child", localField: "children", foreignField:"customId", as:"joinedChildren"}})

在 mongo shell 中正确运行,但会导致

Error:
TypeError: pipeline[(pipeline.length - 1)] is undefined :
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1292:9
DBCollection.prototype.aggregate@:1:355
@(shell):1:1

在 robo3T 中。

【问题讨论】:

    标签: mongodb robo3t


    【解决方案1】:

    当我将查询包装在 [] 中时,问题就消失了

    db.getCollection('parent').aggregate([{$lookup: {from: "child", localField: "children", foreignField:"customId", as:"joinedChildren"}}])
    

    【讨论】:

      猜你喜欢
      • 2018-08-15
      • 1970-01-01
      • 1970-01-01
      • 2019-06-20
      • 1970-01-01
      • 2020-03-10
      • 1970-01-01
      • 1970-01-01
      • 2018-05-01
      相关资源
      最近更新 更多