jjzjj

aggregatein

全部标签

javascript - 类型错误 : Cannot call method 'toArray' of undefined while aggregatein mongo in node. js

在node.js中进行聚合时出现以下错误。错误:类型错误:无法调用未定义的方法“toArray”doctorsCollection.aggregate([{$project:{"treatments._id":1,"treatments.price":1}},{$unwind:"$treatments"},{$match:{"treatments._id":parseInt(treatments[i])}},{$sort:{"treatments.price":-1}},{$limit:1}]).toArray(function(err,result){console.log(err)