【问题标题】:How to get the field type name in firestore python如何在firestore python中获取字段类型名称
【发布时间】:2021-08-17 03:13:22
【问题描述】:

我们在 Firestore 中有一个数据集。我们想找到现有数据的字段类型。我们的配置是谷歌应用引擎标准中的 Python 3.7。

【问题讨论】:

    标签: python google-cloud-firestore


    【解决方案1】:

    使用 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__
    

    【讨论】:

      猜你喜欢
      • 2020-11-27
      • 1970-01-01
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      • 2016-03-26
      • 1970-01-01
      • 2019-12-29
      • 1970-01-01
      相关资源
      最近更新 更多