I have some problem with the sort() function of mongoskin.
I have a document like this:
{
name: 'Alex',
created: ISODate("2012-05-02T13:07:17.012Z")
},
{
name: 'Jeff',
created: ISODate("2012-05-01T13:07:17.012Z")
}
I want to get all documents sorted by "created" value and in descending order.
I'm trying to get this information using the following code:
mongo.[doc_name].find({...}, {limit: 10, sort:[['created', -1]] }).toArray(
function (err, items){ ... }
);
but it's not working. I'm getting only a random array of data and I don't understand why.
Any help is appreciated. Thank you.