add fields mod
This commit is contained in:
@@ -3,20 +3,25 @@ from firebase_admin import credentials, firestore
|
|||||||
import os
|
import os
|
||||||
from google.cloud.firestore_v1.base_query import FieldFilter
|
from google.cloud.firestore_v1.base_query import FieldFilter
|
||||||
|
|
||||||
key_path = os.getcwd() + '/keys/hpos-af3cc-firebase-adminsdk.json'
|
key_path = os.getcwd() + '/keys/hpos-prod-firebase-adminsdk.json'
|
||||||
cred = credentials.Certificate(key_path)
|
cred = credentials.Certificate(key_path)
|
||||||
firebase_admin.initialize_app(cred)
|
firebase_admin.initialize_app(cred)
|
||||||
def update_incubation(source_collection):
|
def update_incubation(source_collection):
|
||||||
db = firestore.client()
|
db = firestore.client()
|
||||||
|
docs = db.collection(source_collection).where(filter = FieldFilter("_id", "in", ['"565790365511BHAS N"','" 721968131392GAUS N "'])).stream()
|
||||||
docs = db.collection(source_collection).where(filter = FieldFilter("_id", "==", "207296063672UTKLSP3")).stream()
|
|
||||||
|
|
||||||
for doc in docs:
|
for doc in docs:
|
||||||
doc_id = doc.id #doc.to_dict()["_id"]
|
doc_id = doc.id #doc.to_dict()["_id"]
|
||||||
print(doc_id)
|
print(doc_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db.collection(source_collection).document(doc_id).update({"testStatus": False, "incubationTime": "2023-10-12 9:29:00"})
|
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
|
||||||
|
})
|
||||||
print(f"Document with ID '{doc_id}' updated")
|
print(f"Document with ID '{doc_id}' updated")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error updating document with ID '{doc_id}' from the source collection: {e}")
|
print(f"Error updating document with ID '{doc_id}' from the source collection: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user