简体   繁体   English

无法从 Firebase 子集合 Flutter 中获取文档列表

[英]Not able to get a list of documents from Firebase Subcollection Flutter

I am creating an application where I need to have 3 heirarchy for email folders and notes like this:我正在创建一个应用程序,我需要为 email 文件夹和注释提供 3 个层次结构,如下所示: 图表 Now I'm not able to get the list of documents under the folder collection.现在我无法获取文件集合下的文档列表。

I have tried this till now:到目前为止,我已经尝试过了:

var collection = FirebaseFirestore.instance
    .collection('user')
    .doc(widget.email)
    .collection('folder2');
await collection.get().then((snap) {
  data = snap.size;
  print(data);
});

But this is just giving me 0 in the console, but showing all the entries for the notes collection so what should I do?但这只是在控制台中给我 0,但显示了笔记集合的所有条目,所以我该怎么办?

try using the length of the documents retrieved in the result.尝试使用结果中检索到的文档的长度。

var collection = FirebaseFirestore.instance
    .collection('user')
    .doc(widget.email)
    .collection('folder2');
await collection.get().then((snap) {
  data = snap.docs.length;
  print(data);
});

So I did get all the documents in the folder level by simply adding a few fields in that Collection like name, description etc. Though I still don't see a way to get all the documents containing subcollections without adding any fields.所以我确实通过简单地在该集合中添加一些字段(如名称、描述等)来获取文件夹级别的所有文档。尽管我仍然没有看到一种方法来获取包含子集合的所有文档而不添加任何字段。 新建设计

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 Firestore 子集合 flutter 获取所有数据 - get all data from a firestore subcollection flutter flutter 如何显示所有文档的子集合? - flutter how to display a subCollection for all the documents? 从 Firebase 获取信息并能够在 Flutter 中将其与 Gridtile 和 GestureDetector 一起使用 - Get information from Firebase and able to use it with a Gridtile and GestureDetector in Flutter 使用 flutter 从 firebase 获取集合列表 - Get list of collection from firebase using flutter Flutter Firebase 子集合嵌套值查询 - Flutter Firebase Query on nested value in subcollection Flutter firebase query, filter based on subcollection presence - Flutter firebase query, filter based on subcollection presence Flutter Firebase 遍历匹配字段值的所有文档,并将每个文档的字段插入字符串列表 - Flutter Firebase Iterate through all documents that matches field value and inserting field from each one into a List of String 从 firebase flutter 读取文档和字段 - Read Documents and fields from firebase flutter 如何从 Firebase 实时数据库中获取数据到 Flutter 的列表中? - How to get data from Firebase Realtime Database into list in Flutter? 如何从 Firebase Firestore 获取地理点作为列表<latlng>对于 Flutter 中的折线?</latlng> - How to get geopoints from Firebase Firestore as List<LatLng> for a Polyline in Flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM