【发布时间】:2019-10-17 23:30:41
【问题描述】:
我正在收听collection_group 的数据库更改 我无法访问 DocumentSnapshot 的 ref(具有路径)我不断收到错误消息:
AttributeError: 'DocumentSnapshot' object has no attribute 'ref'
这是我的代码:
doc_ref = firestore_db.collection_group(u'collection_name')
doc_ref.on_snapshot(self.__get_snapshot(args))
这是我的 __get_snapshot 方法:
def __get_snapshot(self, args):
def on_snapshot(doc_snapshot, changes, read_time):
for doc in doc_snapshot: #crashes
print(u'Received document snapshot: {}'.format(doc.ref))
for change in changes:
if(change.type.name == "MODIFIED"):
print(change.document.ref) #crashes
print(change.document.get("field"))#this works fine
return on_snapshot
【问题讨论】:
标签: python firebase google-cloud-firestore