嗨,我一直在试图将我的Firestore数据转换为Python 2字典。
doc_ref = db.collection('things1').document('ref1').collection('things2').document('ref2')
doc = doc_ref.get()
给我一个DocumentSnapshot - 我希望得到一个字典。从结果中创建字典的正确方法是什么。尝试了文档,最后得到了对象。我(不)做的事情是愚蠢的。
谢谢
你可以使用to_dict()。这应该给你结果的字典。
doc_ref = db.collection('things1').document('ref1').collection('things2').document('ref2')
doc = doc_ref.get().to_dict()