我想在“社区”集合中找到所有文档,其中用户ID包含在“成员”数组中。
但是我的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,但是我的应用在列表视图中显示了两个社区
答案 0 :(得分:0)
解决了!我发现我的uid在return communityCollection.where('members', arrayContains: uid)