Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore pagination by offset

I would like to create two queries, with pagination option. On the first one I would like to get the first ten records and the second one I would like to get the other all records:

.startAt(0)
.limit(10)

.startAt(9)
.limit(null)

Can anyone confirm that above code is correct for both condition?

like image 344
Umid Boltabaev Avatar asked Nov 03 '25 06:11

Umid Boltabaev


2 Answers

Firestore does not support index or offset based pagination. Your query will not work with these values.

Please read the documentation on pagination carefully. Pagination requires that you provide a document reference (or field values in that document) that defines the next page to query. This means that your pagination will typically start at the beginning of the query results, then progress through them using the last document you see in the prior page.

like image 187
Doug Stevenson Avatar answered Nov 05 '25 01:11

Doug Stevenson


From CollectionReference:

offset(offset) → {Query}

Specifies the offset of the returned results.

like image 45
Efimster Avatar answered Nov 05 '25 01:11

Efimster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!