【发布时间】: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 中。
【问题讨论】: