【发布时间】:2018-11-26 01:09:35
【问题描述】:
有没有办法使用 Flutter 读取 Firestore 中的嵌套集合?我有以下数据结构
Users:
- userId:
- name: value,
- surname: value;
- addresses:
- addressId:
- street:value,
- city: value
我可以使用以下代码读取第一个集合:
Firestore.instance.collection("users").document("userId")
.snapshots().listen((snapShot) {});
有没有办法让我从上面的代码中访问地址,或者我必须运行另一个直接获取地址的命令,如下所示:
Firestore.instance.collection("users").document("userId").
collections("addresses").snapshots().listen((snapShot) {});
【问题讨论】:
-
Firestore.instance .collection('abc') .document("aa") 。 collection('xyz') .getDocuments() .then((QuerySnapshot snapShot) { snapShot.documents.forEach((doc) { print('${doc.documentID}'); print(('${ei.data[ '您的字段名称']}')); }); });
标签: dart google-cloud-firestore flutter