小编Ayi*_*jla的帖子

聚合 `$lookup` 在 MongoDB 中不起作用

当我在集合中使用 $lookup 时,我得到以下错误的输出

这是输出:

{"_pipeline":[{"$project":{"fulldetails":{"$concat":["$associate_name"," ","$associate_no"]},"outlets":"$outl"}},{"$lookup":{"from":"outlets","localField":"_id","foreignField":"associate_id","as":"outl"}}],"options":{}}
Run Code Online (Sandbox Code Playgroud)

这是查询

  var data=Associate.aggregate([{
        $project: {
          "fulldetails": {
            $concat: ["$associate_name", " ", "$associate_no"]
          },
          "outlets": "$outl"
        }
      }, {
        $lookup: {
          from: "outlets",
          localField: "_id",
          foreignField: "associate_id",
          as: "outl"
        }
      }])
Run Code Online (Sandbox Code Playgroud)

提前致谢

mongoose mongodb mongodb-query aggregation-framework

4
推荐指数
1
解决办法
2577
查看次数