I have a collection defined with the following structure:
// Websites
{
_id: "adasdasda",
title: "Site 1",
comments: [{
text: "nice site 2014",
createdOn: "Sat Dec 26 2014 11:28:57 GMT+0100 (CET)"
}, {
text: "nice site 2015",
createdOn: "Sat Dec 26 2015 11:28:57 GMT+0100 (CET)"
}]
}
I want to display this information with a proper order of comments. That means in my case the newest comments first.
I tried using:
Websites.findOne({_id:this.params._id}, {sort:{"comments.createdOn": 1}});
and:
Websites.findOne({_id:this.params._id}, {sort:{"comments.createdOn": -1}});
but the order remains unchanged - the oldest comments first.
Any idea what I'm missing?