Swift:解析服务器检索数据范围10 ... 20

时间:2018-07-26 20:35:09

标签: swift parse-server

我想按范围从数据库中检索数据,即我想例如在第5个与第20个对象之间检索该怎么做:

我正在寻找一个看起来像这样的函数

let query = PFQuery(className: "Post")
    query.order(byDescending: "createdAt")
    query.range(range: 5..<20) //I want this, how to do??
    query.limit = 5

1 个答案:

答案 0 :(得分:1)

您可以结合使用limitskip来实现此目的:

https://docs.parseplatform.org/ios/guide/#query-constraints

let query = PFQuery(className: "Post")
query.order(byDescending: "createdAt")
query.skip = 5
query.limit = 20 - 5 // 15 objects