-1
when I will make the requisition to take the amounts of debts and credit of this error:
{
"errors": [
{
"name": "MongoError",
"message": "The 'cursor' option is required, except for aggregate with the explain argument",
"ok": 0,
"errmsg": "The 'cursor' option is required, except for aggregate with the explain argument",
"code": 9,
"codeName": "FailedToParse"
}
]
}
I’ve seen some ways to use, but I don’t work at all, so I read from version 3.6 of Mongo you need to set the course, my version is "mongoose": "^4.7.0"
and the teacher also, in video class he can make the request without using the cursor, he provides the working code, however the error persists here
the code
BillingCycle.route('summary', (req, res, next) => {
BillingCycle.aggregate({
$project: {credit: {$sum: "$credits.value"}, debt: {$sum:
"$debts.value"}}
}, {
$group: {_id: null, credit: {$sum: "$credit"}, debt: {$sum: "$debt"}}
}, {
$project: {_id: 0, credit: 1, debt: 1}
}, (error, result) => {
if(error) {
res.status(500).json({errors: [error]})
} else {
res.json(result[0] || { credit: 0, debt: 0 })
}
})
})
if you can place exactly where the cursor should be in this code would appreciate it very much, thanks from now.
I advise you to work on the latest version of Mongoose. If this is not possible this cursor error can be solved in the "Mongoose" version: "4.13.7"
– jcardoso