Filtered paginated list with firebase

前端 未结 1 1377
逝去的感伤
逝去的感伤 2021-01-24 03:46

I\'m trying to make a paginated filtered list with firebase and swift (but feel free to answer with the programming language that you like the most) without filter the retrieved

相关标签:
1条回答
  • 2021-01-24 04:37

    If I recall correctly, you can pass in the key of the first item to return as a second argument to queryStarting. From the documentation (emphasis mine):

    queryStartingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. The FIRDatabaseQueryinstance returned by queryStartingAtValue:childKey will respond to events at nodes with a value greater than startValue, or equal to startValue and with a key greater than or equal to childKey.

    So in code that would then be:

    matchesRef
        .queryOrdered(byChild: "users/user-1")
        .queryStarting(atValue: "ok", childKey: "<last-fetched-user-id>")
        .queryLimited(toFirst: 5)
        .observe(.value, with: { snapshot in
    
    0 讨论(0)
提交回复
热议问题