Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda