Start a new topic

Adding a sort to my custom endpoint


Currently, I'm not familiar with the custom endpoints. This is how I retrieve an equivalent to sql "SELECT DISTINCT(country) FROM Track".

function onRequest(request, response, modules) { modules.collectionAccess.collection('Track').distinct('country', function (err, docs) { if (err) { logger.error('Query failed: '+ err); } else { response.body = docs; response.complete(200); } }); }


Could you help me to add an equivalent to "SORT BY country ASC" ?

Thank you.

Good morning Fabreax:

You can only specify a query for distinct in Mongo, but not a sort.  There aren't really any ways around this, as it's a limitation of mongo, and not of Kinvey.


Thank you ! I understand. I will sort them myself !

Thanks for your understanding fabreax, I will make a note of this as it's something we may want to consider going forward.   Thanks.

Login or Signup to post a comment