Skip to content

Pagination #9

Closed
Closed

Description

@sammy-SC

It would be awesome to have pagination. For large data sets it is necessary.

Activity

  1. asciimike commented on Sep 20, 2015

    @asciimike
    Contributor

    @sammy-SC yep, we're investigating the best way to do this (we'd really like a count aggregation function in the client first), as FirebaseUtil does it but not in an ideal way.

    I think this was planned originally for right after authentication, as we'll need to add another array and some properties for tracking which items exist where.

  2. kermankohli commented on Nov 1, 2015

    @kermankohli

    Any updates on this? Also what would define a "large collection" - at what point does performance degrade due to a lack of paging?

  3. puf commented on Nov 1, 2015

    @puf
    Contributor

    We're still working on other features. Pull-requests are always welcome.

  4. jhnferraris commented on May 25, 2016

    @jhnferraris

    Any news about this feature?

  5. asciimike commented on May 26, 2016

    @asciimike
    Contributor

    No, though I'm planning a refactor of the underlying data structure at some point and might get around to adding new features.

  6. kutakmir commented on Jun 19, 2016

    @kutakmir

    I see this as a huge limitation Firebase has. Seriously, this is making it useless for virtually any app with a longer list.
    @mcdonamp @jhnferraris @kermankohli @sammy-SC @puf
    I am new to Firebase and have very little time for this, but how about having a live session and put it together? I am available in CET working hours.

    EDIT: feel free to ping me on skype: Haunebu512

  7. jhnferraris commented on Jun 19, 2016

    @jhnferraris

    Hello,

    We've tried doing our own pagination for Firebase. We've tried @timominous approach. See here (http://stackoverflow.com/questions/37430881/swift-ios-firebase-paging). Maybe this can help kick off the solution of the pagination problem.

  8. kutakmir commented on Jun 20, 2016

    @kutakmir

    Do you got it working correctly? Could you perhaps share the whole paginating solution with the rest of us?

  9. jhnferraris commented on Jun 20, 2016

    @jhnferraris

    @kutakmir

    Yes. We just followed the sample usage in the attached SO link.

    var count = numberOfItemsPerPage
    
    var query ref.queryOrderedByKey()
    
    if startKey != nil {
      query = query.queryStartingAtValue(startKey)
      count += 1
    }
    
    query.queryLimitedToFirst(UInt(count)).observeSingleEventOfType(.Value, withBlock: { snapshot in
      guard var children = snapshot.children.allObjects as? [FIRDataSnapshot] else {
        // Handle error
        return
      }
    
      if startKey != nil && !children.isEmpty {
        children.removeFirst()
      }
    
      // Do something with children
    })
    

    The solution might depend on how the scrollable list would work but I think the same logic applies. Here's the pseudocode that we used:

    1. If startKey is null, then it is page 1.
    2. Somewhere in your model, save the key of the last of object of page 1 and set that to "startKey"
    3. Use the value of startKey to get page 2, remove the first child since it will now be a duplicate with the last value of page 1.
  10. kutakmir commented on Jun 20, 2016

    @kutakmir

    How about the newly created, edited and removed items in the paginated list?

  11. asciimike commented on Jun 20, 2016

    @asciimike
    Contributor

    I strongly recommend folks look at the FirebaseUtil Paginate API, as it has properly implemented all the child_* methods, and has a number of other useful features. Porting this over to iOS and Android is something that we'd love, and is something we think the community would benefit from--as Puf said, PR's are always welcome :)

  12. timominous commented on Jun 23, 2016

    @timominous

    @kutakmir Unfortunately, the logic provided in the SO link doesn't have listeners for events.

    @mcdonamp I found this (googlearchive/firebase-util#51) and would like to think the team is already working on it. :) I would have to re-study JS if I'd have some time to port it over.

  13. asciimike commented on Jun 23, 2016

    @asciimike
    Contributor

    @timominous that is in reference to this issue (though it wasn't exposed at the time), so just stay tuned to this thread for the latest :)

  14. 14 remaining items

  15. svidata commented on Feb 13, 2018

    @svidata

    @mcdonamp thank you for your quick reply. You are saying that this support is never likely to be added but issue #17 in android and issue #9 in iOS are still set as open as you can tell. How come we have not been informed about this in those threads? Now, this means that we are expected to move everything to Firestore? Given that Firestore is still in beta mode??

  16. asciimike commented on Feb 13, 2018

    @asciimike
    Contributor

    Let me clarify. It's highly unlikely that anyone from the Firebase team will add support for this in the existing Realtime Database, given that it's 1) inefficient (done client side), and 2) we're putting more effort into Firestore (which does it more efficiently, server side).

    FirebaseUI is an open source project, which means anyone can contribute this feature if they'd like (and ideally, do so on both platforms), hence issues being kept open. Happy to close these and let the community re-open (or submit a PR) if that would make folks happier.

  17. svidata commented on Feb 13, 2018

    @svidata

    @mcdonamp How about the fact that Firestore is still in beta mode and more expensive than realtime database (Document writes Document reads Document deletes)?

  18. asciimike commented on Feb 13, 2018

    @asciimike
    Contributor

    There are several threads on related topics on Google Cloud Firestore Discuss, so I'd voice concerns there.

    @morganchen12 (iOS), @samtstern (Android), and I are happy to review PRs for this feature, but again, it's unlikely we'll be able to contribute significant implementation.

  19. samtstern commented on Feb 13, 2018

    @samtstern
    Contributor

    If anyone reading this wants to send a PR, as @mcdonamp said, that's great but please outline your design in an issue first. This is a really really tricky issue to get right (@morganchen12, @puf and me have all made some attempt) and I wouldn't want anyone to waste their time coding before knowing if they were heading in the right direction.

  20. tillchen commented on Jan 7, 2020

    @tillchen

    Any news guys? It's 2020 now 😆

  21. cosmopolit commented on Feb 16, 2022

    @cosmopolit

    Time is running faster.. now we are in 2022 and after reading this i am a bit disappointed because i must write my own soloution :)

  22. reopened this on Jun 9, 2026
  23. github-actions commented on Jul 8, 2026

    @github-actions

    Hello, to help manage issues we automatically close stale issues.

    This issue has been automatically marked as stale because it has not had activity for quite some time. If it is still relevant, leave a comment to keep it open.

    This issue will be closed in 15 days if no further activity occurs.

    Thank you for your contributions.

  24. russellwheatley commented on Aug 3, 2026

    @russellwheatley
    Member

    Given this has been open for 11 years and no PR has been opened to address it, I'm going to close it out. If someone wants to open a PR, they're more than welcome, I'm happy to review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions