I have this documents with a date field, and i am passing the DATA to my views and printing there, now i need order the data by the date, for example:
20/01/2015 Appears on top of 19/01/2015.
My schema object is:
schema = {
name: String,
date: String,
}
The format of the date is DAY/MONTH/YEAR.
I already try to sort, i searched before ask here, this is the actual code:
MyModel.find().sort('date').exec(function(err, result) {
if (err) {
console.log(err);
}
else {
res.render('index', {
data: result,
});
}
});
What i am doing wrong??
Thanks!!!!