仅当将新文档添加到Firebase中的特定集合中时,代码才应触发。
我已经在javascript中找到了answer来解决此问题,但是我找不到python的解决方案。
答案 0 :(得分:0)
documentation包含如何执行此操作的示例(请查看“ python”标签):
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)