Search code examples
swiftparse-server

Swift: Parse server retrieve data range 10...20


I would like retrieve data from the database, by range, ie I want to retrieve for example between the 5th and the 20th object, how to do:

I am looking for a function that will look like:

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

Solution

  • You can use a combination of limit and skip in order to achieve this:

    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