猫鼬聚集并填充

时间:2018-07-03 11:30:10

标签: mongodb mongoose aggregation-framework mongoose-schema

聚合函数和多个填充如何一起离开? 此代码返回“ TypeError:Installation.populate(...)。exec不是函数”

tableA.aggregate(                        
      [            
            {
                  $lookup: {
                        from: "tableB",
                        localField: "_id",
                        foreignField: "_id",
                        as: "TableB"
                  }
            },
            {
                  $unwind: { path: "$TableB"}
            },             
            {
                  $match: {"TableB.Email" : "orixaf@gmail.com"}                                    
            }                             
      ]
,function (err, results) {

     tableA.populate(results,'Parent','Company').exec(function(err, results) {

            tableA.count(filter).exec(function(err, count) {
                  res.send({ success: true, results: results, total: count });
            });
      });

});

0 个答案:

没有答案