Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Find number of entries in firebase document

I am trying to do pagination with a Firestore database. Is there a way for me to find the number of documents in my Firestore from my website using Javascript so that I can code my (prev) and (next) buttons for pagination accordingly?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

When it comes to Firestore, you can only request pages of data of a particular size using the limit() function. That being said, you can start from the beginning of a query, and get the following pages of the same size. This operation should continue with other similar operations until there are no more documents left.

So you have to always start from page one, then go forward through the pages using the query cursors, by specifying which document was the last one in the previous query.

Unfortunately, there is no way you can jump between pages. You always have to read all the prior pages. Besides that, since the collections in Firestore don't maintain a document count, you won't be able to know how many pages of data there are ahead of time unless you create and maintain your own count of documents.

If you want to implement a modern way for handling pagination, you should consider implementing that so-called "infinite scroll". Facebook does that, Instagram does that. There are many examples out there.

I have also written an article called:

  • How to count the number of documents in a Firestore collection?

Where I have explained how you can count documents in Firestore.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!