From 0ef6bb2ae093dde2b951762bfa4b214dfd8800d3 Mon Sep 17 00:00:00 2001 From: Mariya Varghese Date: Fri, 11 Aug 2023 13:32:13 +0000 Subject: [PATCH] Change TestStaus to false --- changeTestStatus | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 changeTestStatus diff --git a/changeTestStatus b/changeTestStatus new file mode 100644 index 0000000..8eb957a --- /dev/null +++ b/changeTestStatus @@ -0,0 +1,29 @@ +import firebase_admin +from firebase_admin import credentials, firestore + +# Replace 'path/to/your/serviceAccountKey.json' with the actual path to your service account JSON file +cred = credentials.Certificate(r'C:\Users\smila\PycharmProjects\pythonqueries\hpos-af3cc-firebase-adminsdk-n261k-6ff4a63c54.json') +firebase_admin.initialize_app(cred) +def move_documents(source_collection): + db = firestore.client() + + # Get all documents from the source collection + source_docs = db.collection(source_collection).get() + + for doc in source_docs: + # Extract the document ID + doc_id = doc.id + + # Get the document data + doc_data = doc.to_dict() + + try: + # Delete the document from the source collection + db.collection(source_collection).document(doc_id).update({"testStatus": False}) + print(f"Document with ID '{doc_id}' updated") + except Exception as e: + print(f"Error deleting document with ID '{doc_id}' from the source collection: {e}") + +if __name__ == "__main__": + # Replace 'source_collection' and 'destination_collection' with your collection names + move_documents("patientData")