Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoError: The 'cursor' option is required, except for aggregate with the explain argument

I am using latest version of mongodb 3.6 even after getting following error...

MongoError: The 'cursor' option is required, except for aggregate with the explain argument

const user = await User.aggregate([
      { $group: {
          _id: '$_id',
          domain: { $push: "$domain" },
          domain: { $push: "$email" },
          domain: { $push: "$userName" }
        }
      }
    ])
like image 226
Ashh Avatar asked Apr 30 '18 12:04

Ashh


1 Answers

Thanks @Neil Lunn

Update mongoose. Mongoose versions prior to 5.0 are incorrectly matched for MongoDB 3.6. MongoDB 3.6 changed the aggregate API from "cursor optional" to "cursor only", and older mongoose versions break this by trying to invoke a deprecated way to ask for an array in response.

like image 101
Ashh Avatar answered Nov 19 '22 04:11

Ashh