Skip to content

Firestore query-cursors/pagination: Added Query.startAfter (Android, iOS, js) #219

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Mar 19, 2022

Conversation

tiagonuneslx
Copy link
Contributor

@tiagonuneslx tiagonuneslx commented Sep 15, 2021

Makes it possible to do basic pagination in Firestore.

Most basic example usage:

val firstPage = collectionReference.limit(10).get() // First 10 results
val lastDocumentSnapshot = firstPage.documents.lastOrNull() ?: return
val secondPage = collectionReference.startAfter(lastDocumentSnapshot).limit(10).get() // Second 10 results

Documentation:
https://firebase.google.com/docs/firestore/query-data/query-cursors

Example on how to do pagination using the Android native library:
https://medium.com/@ericampire/firestore-pagination-with-paging-3-762e371cc57f

Fixes part of #206

@Reedyuk Reedyuk requested a review from nbransby October 4, 2021 10:17
@nbransby
Copy link
Member

nbransby commented Oct 4, 2021

@tiagonuneslx thank you for your contribution! could you add a test to for startAfter to this PR?

@tiagonuneslx
Copy link
Contributor Author

@nbransby done!

@nbransby nbransby merged commit a393f27 into GitLiveApp:master Mar 19, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants