Save speaking asynchronously

This commit is contained in:
Cristiano Ferreira
2023-12-10 15:38:26 +00:00
parent 50c39e5f9c
commit 9f4aed52ae
3 changed files with 91 additions and 63 deletions

View File

@@ -59,4 +59,18 @@ def save_to_db(collection: str, item):
return (False, None)
def save_to_db_with_id(collection: str, item, id: str):
db = firestore.client()
collection_ref = db.collection(collection)
# Reference to the specific document with the desired ID
document_ref = collection_ref.document(id)
# Set the data to the document
document_ref.set(item)
if document_ref:
print(f"Document added with ID: {document_ref.id}")
return (True, document_ref.id)
else:
return (False, None)