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

253
Views
How to dynamically get firestore subcollections and their contents?

I want to iterate through a list of subcollections inside my top-level collection and retrieve their data one by one, without first knowing the names of said subcollections. The subcollections canbe created by users, so I won't know their names/IDs ahead of time.

I've seen a couple of answers on here about getting subcollections, but they all seem to be with hardcoded collection names. Example A Example B

When I pull and console log out my toplevel herbalTeas collection currently, I just see a piece of dummy data. What I'd like to see is all my other subcollections (which are currently mint and chamomile, but could grow dynamically) in my console as well, so I can iterate and do things with their data.

See screenshot below of by firestore structure.

I'm console logging that data via this code:

const collectionRef = await getDocs(collection(db, "herbalTeas"));
collectionRef.forEach((doc) => {
  console.log(doc.data()); // logs out {test: "test}
});

Firestore

about 4 years ago · Juan Pablo Isaza
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!