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?
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.