我正在监听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