1

Lets say I have a queue in a firebase collection, and I want to access the 50th item to the 100th item in that queue. How would I do that? It seems I can only access the queue from the front.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Andrew Hsu
  • 61
  • 1
  • 6

1 Answers1

1

Firestore queries are not index based. So to read the nth document from a collection, you'll need to:

  1. Create a query that orders on a certain field or key.
  2. Read the first N documents by calling limit().
  3. Ignore the first N-1 documents.

The only alternative way to do this is to store the index in each document, which is known as a ranking (because of its most frequent use in leaderboards). For more on how to do that, see Leaderboard ranking with Firebase

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • after we ignore the first n-1 documents how do we access the documents after that? Not sure how to hold that place in line for the queue – Andrew Hsu Jan 16 '20 at 05:18