Skip to content

Commit

Permalink
docs(firestore): on_snapshot document changes (#79)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
crwilcox and HemangChothani committed Jul 6, 2020
1 parent 1415bc4 commit c556fc5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions google/cloud/firestore_v1/collection.py
Expand Up @@ -459,7 +459,8 @@ def on_snapshot(self, callback):
provided callback is run on the snapshot of the documents.
Args:
callback (Callable[[:class:`~google.cloud.firestore.collection.CollectionSnapshot`], NoneType]):
callback (Callable[List[:class:`~google.cloud.firestore_v1.collection.CollectionSnapshot`], \
List[:class:`~google.cloud.firestore_v1.watch.DocumentChange`], datetime.datetime], NoneType):
a callback to run when a change occurs.
Example:
Expand All @@ -468,8 +469,8 @@ def on_snapshot(self, callback):
db = firestore_v1.Client()
collection_ref = db.collection(u'users')
def on_snapshot(collection_snapshot, changes, read_time):
for doc in collection_snapshot.documents:
def on_snapshot(docs, changes, read_time):
for doc in docs:
print(u'{} => {}'.format(doc.id, doc.to_dict()))
# Watch this collection
Expand Down
9 changes: 5 additions & 4 deletions google/cloud/firestore_v1/document.py
Expand Up @@ -500,7 +500,8 @@ def on_snapshot(self, callback):
provided callback is run on the snapshot.
Args:
callback(Callable[[:class:`~google.cloud.firestore.document.DocumentSnapshot`], NoneType]):
callback (Callable[List[:class:`~google.cloud.firestore_v1.document.DocumentSnapshot`], \
List[:class:`~google.cloud.firestore_v1.watch.DocumentChange`], datetime.datetime], NoneType):
a callback to run when a change occurs
Example:
Expand All @@ -512,9 +513,9 @@ def on_snapshot(self, callback):
db = firestore_v1.Client()
collection_ref = db.collection(u'users')
def on_snapshot(document_snapshot, changes, read_time):
doc = document_snapshot
print(u'{} => {}'.format(doc.id, doc.to_dict()))
def on_snapshot(docs, changes, read_time):
for doc in docs:
print(u'{} => {}'.format(doc.id, doc.to_dict()))
doc_ref = db.collection(u'users').document(
u'alovelace' + unique_resource_id())
Expand Down
3 changes: 2 additions & 1 deletion google/cloud/firestore_v1/query.py
Expand Up @@ -878,7 +878,8 @@ def on_snapshot(self, callback):
provided callback is run on the snapshot of the documents.
Args:
callback(Callable[[:class:`~google.cloud.firestore.query.QuerySnapshot`], NoneType]):
callback (Callable[List[:class:`~google.cloud.firestore_v1.query.QuerySnapshot`], \
List[:class:`~google.cloud.firestore_v1.watch.DocumentChange`], datetime.datetime], NoneType):
a callback to run when a change occurs.
Example:
Expand Down

0 comments on commit c556fc5

Please sign in to comment.