I am updating a website for a scavenger hunt built on NodeJS and MongoDB and i'm having issues with the scoreboard feature.
All my environment variables are identical on my local machine and the live site but when it is deployed I get the error
"MongoError: The 'cursor' option is required, except for aggregate with the explain argument"
below is the aggregate I am using
module.exports.getScores = (callback) => {
Team.aggregate([
{ $group: {
_id: "$code",
name: { $first: "$name"},
total: { $sum: "$score"}
}}
],
(err, results) => {
if (err) {
callback(err);
console.error(err);
} else {
callback(null, results);
}
}
);
}
I've google the issue and all solutions i've found seem not to work which is why I am posting.
NodeJS Version:8.10.0
MongoDB Version: 3.6.12