Home > Blockchain >  How to get the second 10 document in a Firestore Query?
How to get the second 10 document in a Firestore Query?

Time:09-22

More precisely, a slice of the ordered documents. My idea would be this, but it isn't good:

firestore().collection("queue").orderBy("order_id", "asc").limit(3,5)

I'd be grateful if anyone could answer it.

CodePudding user response:

Best Practice

"Do not use offsets. Instead, use cursors. Using an offset only avoids returning the skipped documents to your application, but these documents are still retrieved internally. The skipped documents affect the latency of the query, and your application is billed for the read operations required to retrieve them."

CodePudding user response:

Firestore does not offer offset-based query results for web and mobile clients, as they are inefficient and costly on your bill. If you want to implement pagination in your app, you should follow the linked documentation and design your app accordingly. This will get you the ability to jump forward and backward in query results, but not to a specific index or offset without first reading everything up to that offset (which is the expensive part that Firestore is suggesting you should not do).

  • Related