2023-10-12 13:40:36 +05:30
|
|
|
import firebase_admin
|
|
|
|
|
from firebase_admin import credentials, firestore
|
|
|
|
|
import os
|
|
|
|
|
from google.cloud.firestore_v1.base_query import FieldFilter
|
|
|
|
|
|
2023-12-08 21:48:17 +05:30
|
|
|
key_path = os.getcwd() + '/keys/hpos-prod-firebase-adminsdk.json'
|
2023-10-12 13:40:36 +05:30
|
|
|
cred = credentials.Certificate(key_path)
|
|
|
|
|
firebase_admin.initialize_app(cred)
|
|
|
|
|
def update_incubation(source_collection):
|
|
|
|
|
db = firestore.client()
|
2023-12-08 21:48:17 +05:30
|
|
|
docs = db.collection(source_collection).where(filter = FieldFilter("_id", "in", ['"565790365511BHAS N"','" 721968131392GAUS N "'])).stream()
|
2023-10-12 13:40:36 +05:30
|
|
|
|
|
|
|
|
for doc in docs:
|
|
|
|
|
doc_id = doc.id #doc.to_dict()["_id"]
|
|
|
|
|
print(doc_id)
|
|
|
|
|
|
|
|
|
|
try:
|
2023-12-08 21:48:17 +05:30
|
|
|
db.collection(source_collection).document(doc_id).update({
|
|
|
|
|
# "bloodGroup": "B+",
|
|
|
|
|
"testStatus": False,
|
|
|
|
|
# "createdAt": "2023-11-11 07:05:00",
|
|
|
|
|
"incubationTime": "2023-12-08 14:05:00",
|
|
|
|
|
"incubationModified": True
|
|
|
|
|
})
|
2023-10-12 13:40:36 +05:30
|
|
|
print(f"Document with ID '{doc_id}' updated")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"Error updating document with ID '{doc_id}' from the source collection: {e}")
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
update_incubation("patientData")
|