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

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

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 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