Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(firestore): on_snapshot document changes #79

Merged
merged 9 commits into from Jul 6, 2020
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