import firebase_admin
from firebase_admin import credentials, firestore
cred = credentials.Certificate(_auth_data)
firebase_admin.initialize_app(cred)
db = firestore.client()
# doc is a DocumentReference
doc = db.collection('MyCollection').document('MyDoc')
# first get() returns a DocumentSnapshot, second returns any field
polizas = doc.get().get('polizas')
# polizas now is a list of dicts
# read any field or iterate as you want
print(polizas[0]['numeroPoliza'])
for pol in polizas:
print(pol['numeroPoliza'])
1条答案
按热度按时间vltsax251#
你的问题不太清楚,但我认为没有比这更好的解决办法了:
首先,获取包含数组的整个字段(此处为:
'polizias'
),或者甚至是整个文件。然后,在代码中对这个数组做任何你想做的事情,它变成了一个Python列表。
示例: