2
在node.js.中執行聚合時出現以下錯誤。TypeError:無法在node.js中調用方法'toArray'undefined while aggregatein mongo
錯誤:類型錯誤:無法調用「指定者」未定義
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);
});
我不知道發生了什麼事情。任何幫助,將不勝感激。謝謝!
'.aggregate'方法在特定版本的驅動程序之前不會返回遊標,或者您未指定將遊標作爲選項指定。直接傳遞迴調以獲得結果。 –