【发布时间】:2021-01-28 13:39:42
【问题描述】:
我正在寻找一种通过另一个 ID 流获取文档流的方法,假设我有一个像 Stream<List<String>> docIds = ['3dd34334, '45454de', ...] 这样的文档 ID 流,那么我需要使用我已经拥有的 ID 查询另一个集合,请查找我下面的代码返回一个空流。
Stream<List<ViewModel>> matches(uid) async {
Stream<List<String>> docIds = FirebaseFirestore.instance
.collection('matches')
.where('match', arrayContains: uid)
.snapshots()
.map((event) => event.docs.map((e) => e.id).toList());
return docIds.map((e) {
e.map((e) => FirebaseFirestore.instance
.collection('matches')
.doc(e)
.collection("myCollection")
.snapshots()
.map(
(event) => event.docs.map((e) => ViewModel.fromJson(e.data())).toList(),
));
}).toList();
}
【问题讨论】:
标签: flutter google-cloud-firestore stream