I'm new with NodeJS and MongoDB and I encounter an issue when I want to execute a Find() query with a Sort() using Mongoose.
I would like to sort my results by notifications date and it doesn't work
Here's my Query:
UsersNotifications
.find({user_id: new ObjectId(req.user._id)})
.sort({'notifications.date': -1})
.select('notifications').exec().then(usersNotifications => {
res.locals.usersNotifications = usersNotifications;
});
Here's my models:
Thank you for your help !
