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

106
Vistas
Fetch firebase nested subcollections for multiple documents with 'where'

I'm creating a simple web application and want to fetch 10 particular posts replies at a time by their postIds.

I'm using Firebase firestore, here is my database design posts/{postDocument}/replies/{replyDocument}.

Reply here is a document inside a collection replies which contains into a document post

My use case is that I want to fetch 10 posts at a time and so for each post also its subcollection (replies)

If I do a loop like for each postDocumentId await fetchReplies(postDocumentId) it will take too much time for one iteration (10 iterations overall)

I want to achieve something like this:

  let postIds = [ '123', '321', '221','123', '021', '621','423', '521', '291','251' ]
  let snapshot = await firestore()
          .collection('posts/replies')
          .where('postId', 'in', postIds)
          .get();

In the end I want to get data from firebase the most optimal way and get it in this type:

[{post:{...},
replies:[{...},{...}]},
{post:{...},
replies:[{...},{...}]},
{post:{...},
replies:[{...},{...}]},
{post:{...},
replies:[{...},{...}]},
{post:{...},
replies:[{...},{...}]}]

Thank you in advance

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can read documents from all replies collections with a collection group query.

But there's no way to limit that to the replies collections under a specific set of document IDs, unless those document IDs are also in the replies documents.

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