【问题标题】:How to get document ids of a firestore collection如何获取 Firestore 集合的文档 ID
【发布时间】:2019-09-24 00:12:41
【问题描述】:

这是我的 Firestore 结构。我想将“RecodeBook”集合的文档 ID 放入 dart 中的列表中。

我在这里到处寻找解决方案。但我找不到。

here is the image link of firestore

【问题讨论】:

    标签: firebase dart flutter google-cloud-firestore


    【解决方案1】:

    使用 getDocuments() 方法,您将得到查询快照。使用 .documents 获取 DocumentSnapshot。循环打印他们的 documentId。

    QuerySnapshot querySnapshot = await Firestore.instance.collection("RecodeBook").getDocuments();
    var list = querySnapshot.documents;
    list.forEach((f) {
      print(f.documentID);
    });
    

    【讨论】:

      猜你喜欢
      • 2018-04-04
      • 2021-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-14
      • 1970-01-01
      相关资源
      最近更新 更多