parse.com - query by highest values?
-
20-12-2019 - |
Question
I have a Photo class and one of it's fields is commentsCount, a number. I want to query the Photo class to return the photos with the most comments. If I have a small number of photo objects, then I just query for them and orderByDescending.
However, I haven't been able to test this with a large number of objects.
- Does orderByDescending sort only the returnedObjects?
- Or does it sort all the objects in the database and return topmost results?
If it only sorts the returnedObjects, how can I write a Parse query to return the topmost results?
Solution
--data-urlencode 'order=-commentsCount'
--data-urlencode 'limit=20'
--data-urlencode 'skip=0'
Above will get you page 1 ( starts with highest value )
Below will page to the next 20 highest values ( page 2 )
--data-urlencode 'order=-commentsCount'
--data-urlencode 'limit=20'
--data-urlencode 'skip=20'
Above from RestAPI manual(Queries section).
Note the minus sign in order parm value.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow