I am getting The 'cursor' option is required error from every mongoose aggregate of a particular nodeJS application. But In that same system other applications having mongoose aggregate working fine. What is the fix? BTW the same application is working fine in other system
Code
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);
})
});
}
Error
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...