-
-
Save ankurg22/c709417ea0bb4cf21ae3a434091c9d74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To observe new records being added. | |
firestoreDb.collection(collectionPath) | |
.orderBy("created_at", Direction.ASCENDING) | |
.startAfter(currentTimestamp) | |
.addSnapshotListener(...) | |
// To observe last N records | |
firestoreDb.collection(collectionPath) | |
.orderBy("created_at", Direction.ASCENDING) | |
.endBefore(currentTimestamp) | |
.limitToLast(10) // N = 10 | |
.addSnapshotListener(...) | |
// To observe last N to 2N records | |
firestoreDb.collection(collectionPath) | |
.orderBy("created_at", Direction.ASCENDING) | |
.endBefore(lastRecordTimestamp) | |
.limitToLast(10) // N = 10 | |
.addSnapshotListener(...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment