为了账号安全,请及时绑定邮箱和手机立即绑定

Firestore:使用 python 列出文档的子集合

Firestore:使用 python 列出文档的子集合

catspeake 2022-12-27 17:16:20
是否可以使用 python 列出文档的子集合?谷歌文档似乎不一致他们在这里说 get collections 方法在 Python 客户端库中不可用:https://firebase.google.com/docs/firestore/query-data/get-data#python_6他们在这里说 class collections() 列出子集合:https://googleapis.dev/python/firestore/latest/document.html所以我尝试类似的东西:collnameref = db.collection(collname)docs = collnameref.stream()for doc in docs:    print (doc.collections())但它不起作用。
查看完整描述

1 回答

?
智慧大石

TA贡献1946条经验 获得超3个赞

你是对的。文档中缺少此内容:


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)


查看完整回答
反对 回复 2022-12-27
  • 1 回答
  • 0 关注
  • 132 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号