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

149
Views
Firestore - Get amount of fields in document

I have a document with some fields. I want to get the amount of fields.

For Example:

enter image description here

I will get 5.

My Code:

const data = await firestore()
            .collection(groupID)
            .doc('jobs-list')
            .get()
            .then((value) => {
                console.log(value.data.length); // Returns 0
                console.log(value.data()["1"]);
            })

I want to log 5
How do I do this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There's no direct way in Firestore to get the count of your fields. You can do it by using Object.keys() method as the result you would get in Firestore is an object. See sample code below:

const data = await firestore()
            .collection(groupID)
            .doc('jobs-list')
            .get()
            .then((value) => {
                // This will get the length of the object keys: `5`
                console.log(Object.keys(value.data()).length);
            })
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!