'How do you fetch a list of documents from a firestore collection
so there is a list named List<String> lectures = [lec0, lec3, lec8], and All of the lectures are stored in a collection named lectures. How am I supposed to fetch only the given list of lectures?
Edit: I've created an implementation as follows:
List<String> lectureList = [lec0, lec3, lec8]
CollectionReference get lectures => _db.collection('lectures');
Future<QuerySnapshot> getLectures({required List<String> lectureList}) async {
return await lectures
// FIXME: Check if this works or not
.where(lectureList,
arrayContains:
FieldPath.documentId) // I guess this is kinda incorrect
.orderBy('date')
.get();
}
Is there a better way than this?
Solution 1:[1]
The client-side SDKs for Firestore have no API to get a set of documents by their ID. The closest you can get there is to combine up to 10 IDs in a single call by querying on FieldPath.documentId() and using the in operator.
I recently answered a similar question for Node, so I recommend checking that out too: Bulk way to determine of all paths, which one exists (Possibly in one API Call)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Frank van Puffelen |
