【发布时间】:2020-12-13 05:57:08
【问题描述】:
我一直在努力获取 Firestore 集合中所有文档的列表。我想显示集合中所有文档的所有详细信息。 我的文档树如下询问-
'groups' COLLECTION----->以'groupID'为参考的文档----->'tasks' COLLECTION----->以'taskId'为参考的文档。
现在我想获取特定 groupID 的“任务”集合中的所有文档及其详细信息。
Future<MyTask> getCurrentTask(String groupId) async {
MyTask retVal = MyTask();
try {
DocumentSnapshot _docSnapshot =
await _firestore.collection("groups").document(groupId).collection("tasks").get();
retVal.taskId = taskId;
retVal.taskName = _docSnapshot.data['taskName'];
retVal.dueTime = _docSnapshot.data['dueTime'];
retVal.member =_docSnapshot.data['member'];
retVal.completed = _docSnapshot.data['completed'];
} catch (e) {
print(e);
}
return retVal;
}
我试过了,但它不起作用,因为“方法 'get' 没有为类型 'CollectionReference' 定义。” 请问如何解决这个问题?
【问题讨论】:
-
所以,看这个documentation,好像没有get方法,但是从另一个documentation看来,你可以先做一个查询,以便从收藏。我相信这会很有用。
标签: firebase flutter dart google-cloud-firestore