问题描述
我有一个 Photo 类,其中一个字段是 commentsCount,一个数字.我想查询 Photo 类以返回评论最多的照片.如果我有少量照片对象,那么我只需查询它们并按顺序排序.
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.
- orderByDescending 是否只对返回的对象进行排序?
- 还是对数据库中的所有对象进行排序并返回最上面的结果?
如果只对返回的对象进行排序,我如何编写解析查询以返回最上面的结果?
If it only sorts the returnedObjects, how can I write a Parse query to return the topmost results?
推荐答案
--data-urlencode 'order=-commentsCount'
--data-urlencode 'limit=20'
--data-urlencode 'skip=0'
以上将为您提供第 1 页(从最高值开始)
Above will get you page 1 ( starts with highest value )
下面将分页到接下来的 20 个最高值(第 2 页)
Below will page to the next 20 highest values ( page 2 )
--data-urlencode 'order=-commentsCount'
--data-urlencode 'limit=20'
--data-urlencode 'skip=20'
以上来自 RestAPI 手册(查询部分).
Above from RestAPI manual(Queries section).
注意订单参数值中的减号.
Note the minus sign in order parm value.
这篇关于parse.com - 按最高值查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!