【发布时间】:2020-07-05 08:35:10
【问题描述】:
我想在 'communities' 集合中查找所有文档,其中用户的 id 包含在 'members' 数组中。 但是我的 firebase 查询只是返回“社区”集合中的所有文档,而不仅仅是我查询的文档。
Stream<QuerySnapshot> get userCommunities {
return communityCollection.where('members', arrayContains: uid).orderBy('lastActive', descending: true).snapshots();
}
...
StreamBuilder(
stream: DBService().userCommunities,
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasData)
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
return ListTile(title: Text(snapshot.data.documents[index]['name']));
});
else
return Container();
},
),
testCommunity2 在成员中不包含用户的 ID,但我的应用在列表视图中显示两个社区
【问题讨论】:
-
添加你的数据库截图
标签: firebase flutter google-cloud-firestore