游标'选项是来自每个聚合的必需错误

时间:2018-04-26 19:52:43

标签: javascript node.js mongodb mongoose

我正在接受游标'选项是特定nodeJS应用程序的每个mongoose聚合所需的错误。但在同一系统中,其他具有猫鼬聚合物的应用程序工作正常。 修复是什么? BTW相同的应用程序在其他系统中工作正常

代码

function getTestParams(testconductedid, mark) {
return new Promise(function (resolve, reject) {
    Mark.aggregate([
        {
            $match: {
                testconductedid: testconductedid,
            }
        },
        {
            $group: {
                _id: '$testconductedid',
                max: { $max: '$total' },
                avg: { $avg: '$total' },
                rank: { $sum: { '$cond': [{ '$lt': [mark, "$total"] }, 1, 0] } },
            }
        }
    ], function (err, results) {
        console.log(JSON.stringify(results));
        resolve(results);
    })
});

}

错误

code:9
codeName:"FailedToParse"
errmsg:"The 'cursor' option is required, except for aggregate with the explain argument"
message:"The 'cursor' option is required, except for aggregate with the explain argument"
name:"MongoError"
ok:0
stack:"MongoError: The 'cursor' option is required, except for aggregate with the explain argument\n    at Function.MongoError.create (d:\Ignus\ignuslearn\ignuslearnnode\node_modules\mongoose\node_modules\mongodb-core\lib\error.js:31:11)\n    at commandCallback (d:\Ignus\ignuslearn\ignuslearnnode\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\server.js:1187:66)\n    at Callbacks.emit (d:\Ignus\ignuslearn\ignuslearnnode\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\server.js:119:3)\n    at Connection.messageHandler (d:\Ignus\ignuslearn\ignuslearnnode\node_modules\mongoose\node_modules\mongodb-core\lib\topologies\server.js:358:23)\n    at Socket. (d:\Ignus\ignuslearn\ignuslearnnode\node_modules\mongoose\node_modules\mongodb-core\lib\connection\connection.js:292:22)\n    at emitOne (events.js:116:13)\n    at Socket.emit (events.js:211:7)\n    at addChunk (_stream_readable.js:263:12)\n    at readableAddChunk (_stream_readable.js:250:11)\n    at Socket.Readable.push (_stream_readable.js...

0 个答案:

没有答案