MongoDB Atlas升级到3.6并打破了我客户网站上的聚合功能 . 它抛出了“游标选项是必需的”错误,我修复了 .

但是,当错误消失时,聚合仍然不再运行 . 我在exec()之前,之后和之内设置了console.logs,并且只触发了'before' .

我正在尝试根据购物车的重量检索符合条件的运费:这是一个采样率:

[{
  "_id": "123abc",
  "name":"Free Shipping",
  "rateInfo:[{
   "from":0,
   "to":10000000,
   "rate":0}]
},
{
  "_id": "890xyz",
  "name":"Standard Shipping",
  "rateInfo:[{
   "from":0,
   "to":10000000,
   "rate":10}]
}]

这是MongoDB调用(使用Mongoose):

var data = req.body.data;
    data = JSON.parse(data);
    var weight = JSON.stringify(data.weight);

ShippingModel.aggregate([
  {"$unwind": "$rateInfo"},
  {
    "$match": {
      "$and": [
        {
          'rateInfo.to': {"$gte": weight}
        },
        {
          'rateInfo.from': {"$lte": weight}
        }
      ]
    }
  },
  {
    "$project": {name: 1, _id: 0, "rate": "$rateInfo.rate"}
  },
  {cursor: {}}
]).exec(function(err, shippingRates) {

    //error handling and JSON response

    res.json(shippingRates);

  }
});

我也尝试在exec()之前使用链接游标:

]).cursor({}).exec(function(...

我试过设置批量大小 . 设置explain选项也不起作用:

},
  {explain: true}
]).exec(

我也尝试将它设置为变量,但即使这样也行不通 .

let rates = ShippingModel.aggregate([pipeline]).exec(); 
console.log(rates);

有人可以帮忙吗?