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

145
Views
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 answers
Answer question

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 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!