fra*_*o_b 1 python firebase google-cloud-firestore
是否可以使用 python 列出文档的子集合?好像google文档不和谐
这里他们说 Python 客户端库中没有 get collections 方法:
https://firebase.google.com/docs/firestore/query-data/get-data#python_6
这里他们说类 collections() 列出子集合:
https://googleapis.dev/python/firestore/latest/document.html
所以我尝试这样的事情:
collnameref = db.collection(collname)
docs = collnameref.stream()
for doc in docs:
print (doc.collections())
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
你是对的。文档中缺少这一点:
collnameref = db.collection(collname)
docs = collnameref.stream()
for doc in docs:
# List subcollections in each doc
for collection_ref in doc.reference.collections():
print(collection_ref.parent.path + collection_ref.id)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
955 次 |
| 最近记录: |