我有一个Firestore数据库,其中有“歌手”,然后在每个歌手中都有每个歌手的“歌曲列表”子集合。我能够从主集合中获取数据,但不能从子集合中获取数据。你们可以帮忙吗?
流生成器
StreamBuilder(
stream: Firestore.instance.collection('singers').snapshots(),
ListView.BuilderListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) => SingleChildScrollView(
这是我要显示子集合中数据的地方Text(
snapshot.data.documents[index]['name'],
style: TextStyle(
fontSize: 20, color: Colors.red[500]),
)
数据库最佳答案
您可以通过访问文档内部的子集合来从集合中获取数据,如下所示
Firestore.instance.collection('singers').document('aryana sayeed').collection('song list').snapshots()
要么Firestore.instance.collection('singers/aryana sayeed/song list').snapshots()
关于firebase - 如何从Firestore子集合中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63281304/