This is my Mongodb data...
I'm using this node/mongoose script to get a particular exam sorted by the score.
User.find("completedExams.exam": "test-1").sort({'completedExams.score': -1}).select({'completedExams.$': 1, name: 1}).limit(5).exec(
function(err, allScores) {
if (err) res.status(500).send(err);
res.json(allScores);
});
But I'm getting this. it's not sorting by score