错误:参数必须是aggregate.js中的聚合管道运算符

时间:2019-10-17 20:52:41

标签: javascript node.js mongodb mongoose aggregate

以下是引发错误错误的汇总:错误:参数必须是汇总管道运算符:

DAO.aggregate([
{
  $match: {
  $and: [
  { "period": new mongoose.Types.ObjectId(info.pp) },
  { "status": { $in: options._status } },
  { "per": { $ne: new mongoose.Types.ObjectId(info.me) } }
  ]
  }
},
{
  $lookup: {
  from: "pp",
  localField: "per",
  foreignField: "_id",
  as: "per"
}
},
{ $unwind: { path: "$Per" } },
 { $unwind: { path: "$per.Approver" } },
   {
     $lookup: {
     from: 'people',
     localField: 'Per.Approver.per',
     foreignField: '_id',
     as: 'per'
    }
 },
 {
 $match: {
 $and: nameArray
 }
},
{
  $match: {
  $and: approverArray
}
},
{ $sort: sort },
{ $skip: options._skip },
 { $limit: options._limit }
]).allowDiskUse(true).cursor({batchSize:10}).exec((err, entries) => {
let allData = { total: options._limit, entries}

我遇到以下错误:

error:  Error: Arguments must be aggregate pipeline operators
    at Aggregate.append (/home/ec2-user/app/node_modules/mongoose/lib/aggregate.js:101:11)

这个东西的新手。不知道我是否想念任何东西?

0 个答案:

没有答案