Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.

Commit c556fc5

Browse files
docs(firestore): on_snapshot document changes (#79)
* doc(firestore): change on_snapshot document * doc(firestore): nit * doc(firestore): change in example as not working * doc(firestore): change in document snapshot example Co-authored-by: HemangChothani <hemang.chothani@qlogic.io>
1 parent 1415bc4 commit c556fc5

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

google/cloud/firestore_v1/collection.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ def on_snapshot(self, callback):
459459
provided callback is run on the snapshot of the documents.
460460
461461
Args:
462-
callback (Callable[[:class:`~google.cloud.firestore.collection.CollectionSnapshot`], NoneType]):
462+
callback (Callable[List[:class:`~google.cloud.firestore_v1.collection.CollectionSnapshot`], \
463+
List[:class:`~google.cloud.firestore_v1.watch.DocumentChange`], datetime.datetime], NoneType):
463464
a callback to run when a change occurs.
464465
465466
Example:
@@ -468,8 +469,8 @@ def on_snapshot(self, callback):
468469
db = firestore_v1.Client()
469470
collection_ref = db.collection(u'users')
470471
471-
def on_snapshot(collection_snapshot, changes, read_time):
472-
for doc in collection_snapshot.documents:
472+
def on_snapshot(docs, changes, read_time):
473+
for doc in docs:
473474
print(u'{} => {}'.format(doc.id, doc.to_dict()))
474475
475476
# Watch this collection

google/cloud/firestore_v1/document.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ def on_snapshot(self, callback):
500500
provided callback is run on the snapshot.
501501
502502
Args:
503-
callback(Callable[[:class:`~google.cloud.firestore.document.DocumentSnapshot`], NoneType]):
503+
callback (Callable[List[:class:`~google.cloud.firestore_v1.document.DocumentSnapshot`], \
504+
List[:class:`~google.cloud.firestore_v1.watch.DocumentChange`], datetime.datetime], NoneType):
504505
a callback to run when a change occurs
505506
506507
Example:
@@ -512,9 +513,9 @@ def on_snapshot(self, callback):
512513
db = firestore_v1.Client()
513514
collection_ref = db.collection(u'users')
514515
515-
def on_snapshot(document_snapshot, changes, read_time):
516-
doc = document_snapshot
517-
print(u'{} => {}'.format(doc.id, doc.to_dict()))
516+
def on_snapshot(docs, changes, read_time):
517+
for doc in docs:
518+
print(u'{} => {}'.format(doc.id, doc.to_dict()))
518519
519520
doc_ref = db.collection(u'users').document(
520521
u'alovelace' + unique_resource_id())

google/cloud/firestore_v1/query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,8 @@ def on_snapshot(self, callback):
878878
provided callback is run on the snapshot of the documents.
879879
880880
Args:
881-
callback(Callable[[:class:`~google.cloud.firestore.query.QuerySnapshot`], NoneType]):
881+
callback (Callable[List[:class:`~google.cloud.firestore_v1.query.QuerySnapshot`], \
882+
List[:class:`~google.cloud.firestore_v1.watch.DocumentChange`], datetime.datetime], NoneType):
882883
a callback to run when a change occurs.
883884
884885
Example:

0 commit comments

Comments
 (0)