【发布时间】:2020-05-07 09:26:29
【问题描述】:
我正在编写一个 Python 脚本来读取 Firebase Firestore 数据。不知何故 documentSnapshop.to_dict() 对我不起作用。所以,我写了一个类,参考https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/firestore/cloud-client/snippets.py#L103这个资源。
在我的例子中,城市的位置存储为 GeoPoint firestore 字段。我无法在字典中找到它。我们如何在上面提到的参考示例中提到的 City 类中添加 GeoPoint 位置?
【问题讨论】:
-
Geopoint 具有纬度和经度参数。我猜像
u'latitude': self.location.latitude这样的东西应该可以工作。 -
@EmilGi 感谢您的评论。你能把你的建议写成“城市班”吗?您可以在我分享的示例中找到“城市类”。
标签: python firebase google-cloud-firestore geopoints