How can I order my query using javascript and mongodb on kinvey platform? This is my query
var findData = modules.collectionAccess.collection('myCollection').find({"idColetor": {"$eq": 659238569}}, limit=2);
I've tried
.sort({"tsmilliseconds":-1});
and
$orderby: { tsmilliseconds : -1 }
but anyone is working.
Tks
You should wrap your sort parameter in object and pass it as second parameter in find method. So your method should look like this:
modules.collectionAccess.collection('myCollection').find({"idColetor": {"$eq": 659238569}}, {"limit":2,"sort":{"tsmilliseconds":-1}, function(err, results){});
Here your can find documentation: http://devcenter.kinvey.com/rest/reference/business-logic/reference.html#collection-access-module