in background/function/main.py [0:0]
def update_database(transaction, message):
name = document_name(message)
doc_ref = db.collection('translations').document(document_id=name)
try:
doc_ref.get(transaction=transaction)
except firestore.NotFound:
return # Don't replace an existing translation
transaction.set(doc_ref, message)