【发布时间】:2020-09-05 16:15:02
【问题描述】:
我有以下 Stream 接收组的 Stream 并返回其成员的 Stream。我使用 switchmap 从组快照中获取成员。
但是我有以下问题。我使用带有whereIn 过滤器的where 查询。但问题是 whereIn 根据 firestore 文档只能接收包含 10 个或更少条目的列表
限制 请注意以下对 in 和 数组包含任何:
in 和 array-contains-any 最多支持 10 个比较值。
https://firebase.google.com/docs/firestore/query-data/queries#limitations
所以我在这个场景中处理这个问题时遇到了一些困难。
Stream<List<UserModel>> groupMembersStream(Stream<GroupModel> groupStream) {
return groupStream.switchMap(
(value) => _fireStore
.collection(APIRoutes.users)
.where(FieldPath.documentId, whereIn: value.members.keys.toList(growable: false))
.snapshots()
.map((snapshot) =>
snapshot.documents.map((document) => UserModel.fromFirestore(document)).toList(growable: false)),
);
}
因为我需要以组成员 ID 开头,所以我需要一个 switchMap。所以我不能简单地拆分组成员列表,然后对 10 个 id 的每个块进行单独查询。
那么我该如何处理呢?
【问题讨论】:
标签: flutter dart google-cloud-firestore rxdart