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

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