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

87
Views
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 answers
Answer question

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