From d3cd11397088ffe641c52e644853f52cb01f4524 Mon Sep 17 00:00:00 2001 From: Artem Rys Date: Wed, 15 Apr 2020 08:03:19 +0200 Subject: [PATCH] Make get_check_exists method work as intended. --- firestore/cloud-client/snippets.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/firestore/cloud-client/snippets.py b/firestore/cloud-client/snippets.py index ef06fbe1002..f40766c476d 100644 --- a/firestore/cloud-client/snippets.py +++ b/firestore/cloud-client/snippets.py @@ -15,7 +15,6 @@ from time import sleep from google.cloud import firestore -import google.cloud.exceptions def quickstart_new_instance(): @@ -217,10 +216,10 @@ def get_check_exists(): # [START get_check_exists] doc_ref = db.collection(u'cities').document(u'SF') - try: - doc = doc_ref.get() + doc = doc_ref.get() + if doc.exists: print(u'Document data: {}'.format(doc.to_dict())) - except google.cloud.exceptions.NotFound: + else: print(u'No such document!') # [END get_check_exists]