Question:
Is it possible to retrieve multiple Firestore documents with a single network call using a list of IDs?
Answer:
Yes, there are ways to achieve this using Firestore's SDKs:
Node.js:
firestore.getAll(...documents); // Variant A
let documentRef1 = firestore.doc('col/doc1'); let documentRef2 = firestore.doc('col/doc2'); firestore.getAll(documentRef1, documentRef2).then(docs => {...}); // Variant B
Note: Variant A only works with the Server SDK.
Update:
Firestore now supports IN queries, which provides a more efficient way to retrieve multiple documents by a list of IDs:
myCollection.where(firestore.FieldPath.documentId(), 'in', ["123","456","789"]);
The above is the detailed content of Can I Fetch Multiple Firestore Documents with One Request?. For more information, please follow other related articles on the PHP Chinese website!