2

I am new to python and firestore. But I have some experince on Firebase. I go through the Firestore doc for python. I dont know how to find if task completes successfully or completes with some error. Normally other languages have completion block.

For example I want to know if write completed with success or error for following code:

resp = doc_ref.set({
u'first': u'Alan',
u'last': u'Lovelace',
u'born': 1915
})
Dinesh Kc
  • 91
  • 1
  • 4
  • 1
    Welcome to StackOverflow! Please read the info about [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and [how to give a reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). This will make it much easier for others to help you. – Aditi Mar 06 '18 at 08:55

1 Answers1

1

You can look at the reference for firestore python client. It explains what result an operation returns, what errors it may raise etc.

For example, below is a snippet from the reference for Documents-

create(document_data) Create the current document in the Firestore database.

Parameters: document_data (dict) – Property names and values to use for creating a document. Returns: The write result corresponding to the committed document. A write result contains an update_time field.

Return type: google.cloud.firestore_v1beta1.types.WriteResult

Raises: Conflict – If the document already exists.

You can have try except blocks to capture and handle errors in relevant cases.

And here is an SO post explaining what is a python equivalent of swift completion blocks.

Community
  • 1
  • 1
AsifM
  • 680
  • 9
  • 21