Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda