【发布时间】:2020-09-07 17:26:24
【问题描述】:
有没有一种方法可以获取在 Firestore 中创建的所有文档的特定值?
这就是我的 Firestore 的结构:
我想获取“纬度”和“经度”数据,以便在 mapView 上添加注释。因此,对于每个“帖子”,都会有一个注释。
Firebase 文档中提供的代码(我也在下面分享)似乎对我不起作用,因为我只能获取一个特定路径内所有元素的数据。 p>
let docRef = db.collection("cities").document("SF")
docRef.getDocument { (document, error) in
if let document = document, document.exists {
let dataDescription = document.data().map(String.init(describing:)) ?? "nil"
print("Document data: \(dataDescription)")
} else {
print("Document does not exist")
}
}
问题是,即使我输入了那个特定的路径,我怎么能得到其他路径的“纬度”和“经度”值呢?我还有什么遗漏的吗?
我希望这是有道理的。我是编程新手,并尽力解释。我已经为此苦苦挣扎了两天了。
【问题讨论】:
标签: ios swift firebase google-cloud-firestore annotations