仅听python中对cloud firestore集合的添加
只有将新文档添加到firebase中的特定集合时,才会触发代码 我已经在javascript中找到了解决此问题的方法,但我无法找到python的解决方案。中包含了一个如何解决此问题的示例(请查看“python”选项卡):仅听python中对cloud firestore集合的添加,python,firebase,google-cloud-firestore,Python,Firebase,Google Cloud Firestore,只有将新文档添加到firebase中的特定集合时,才会触发代码 我已经在javascript中找到了解决此问题的方法,但我无法找到python的解决方案。中包含了一个如何解决此问题的示例(请查看“python”选项卡): def on_snapshot(col_snapshot, changes, read_time): print(u'Callback received query snapshot.') print(u'Current cities in California
def on_snapshot(col_snapshot, changes, read_time):
print(u'Callback received query snapshot.')
print(u'Current cities in California: ')
for change in changes:
if change.type.name == 'ADDED':
print(u'New city: {}'.format(change.document.id))
# Removed other cases
col_query = db.collection(u'cities').where(u'state', u'==', u'CA')
# Watch the collection query
query_watch = col_query.on_snapshot(on_snapshot)