【发布时间】:2021-08-17 03:13:22
【问题描述】:
我们在 Firestore 中有一个数据集。我们想找到现有数据的字段类型。我们的配置是谷歌应用引擎标准中的 Python 3.7。
【问题讨论】:
标签: python google-cloud-firestore
我们在 Firestore 中有一个数据集。我们想找到现有数据的字段类型。我们的配置是谷歌应用引擎标准中的 Python 3.7。
【问题讨论】:
标签: python google-cloud-firestore
使用 get() 获取字段对象。然后使用python类型函数获取类名。
document_col_ref = db.collection( u'collection_key' )
document_query = document_col_ref.where(field1', u'==', field_value)
docs = document_query.stream()
docs_array = []
for doc in docs:
docs_array.append(doc)
first_doc = docs_array[0]
field_obj = first_doc.get('field_name')
field_type = type(field_obj)
field_type_value = field_type.__name__
【讨论】: