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

153
Vistas
get multiple docs from firestore by id in single transaction

I have list of firestore documents ids stored in players. Now I want to get all the documents with those ids.

I can use query and in operator, but this is limited to 10 separate values and I expect cases with more than 10. stackoverflow

const colRef = collection(db, "Products");
const q = query(colRef, where(documentId(), 'in', players));

getDocs(q).then((snap) => {
  console.log(snap.docs.map(d => ({ id: d.id, ...d.data() }))
})

I stumbled upon this question where they are using getAll, but this function is not available in firestore 9 AFAIK.

async getUsers({userIds}) {
    const refs = userIds.map(id => this.firestore.doc(`users/${id}`))
    const users = await this.firestore.getAll(...refs)
    console.log(users.map(doc => doc.data()))
}

I could create a list of doc reference and using Promise.all get the data, but this will run the request in parallel, which comes with additional cost as firestore gets billed per request and not per data volume as it is in realtime database.

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

0

they are using getAll, but this function is not available in firestore 9 AFAIK.

Yes, the getAll() is a part of server side NodeJS SDK and not Firebase client SDK.

which comes with additional cost as firestore gets billed per request

Firestore reads are charged on number of documents fetched irrespective of how many queries you run i.e. 5 queries fetching 10 documents each will cost same amount of reads as a single query of 50 documents. At most you'll be charged for SSL overhead depending on the connection.

So one way is to execute multiple queries that'll fetch up to 10 documents each with in operator along with Promise.all() to run them in parallel.

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