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

91
Visualizações
Firestore read counts of documents size

I'm trying to get the amount of documents in a specific collection as the following :

const userCol = db.collection('users').get().then(queryResult => {
   if (queryResult.exists)
       console.log(queryResult.size); // amount of documents
});

So as I use .get() to read the documents that means that I get x reads of the amount of documents exists? If that's true then is there a way to just get the amount of documents without having to read every each one of them?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

First, the amount of read will increase only 1 time in the function you wrote. That is, it does not depend on the number of documents. It depend from the number of times use the get() function. Each use of the get() function means 1 read count. You will access all documents in the users collection, but the amount of read will increase by 1 because you only use get() once.

Note: The definition of .exist applies to the document, not the collection. With the exist command you can poll for the existence of the document, not the collection.

const userCol = db.collection('users').get().then(queryResult => {
   console.log(queryResult.size); // amount of documents
});

or you can also use .listDocuments() property for get documents list in the collection.

const userCol = db.collection('users').listDocuments().then(documentsList => {
   console.log(documentsList.length); // amount of documents
});

Both ways will increase the number of 1 reads.

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