change based on name filter

This commit is contained in:
Pritimay Sarkar
2023-09-11 17:32:11 +05:30
parent 58f3d7d9ef
commit fb430f436c

View File

@@ -1,8 +1,9 @@
import firebase_admin
from firebase_admin import credentials, firestore
import os
from google.cloud.firestore_v1.base_query import FieldFilter
key_path = os.getcwd() + '/scripts/keys/hpos-af3cc-firebase-adminsdk-n261k-2bfd463ec0.json'
key_path = os.getcwd() + '/scripts/keys/hpos-preprod-firebase-adminsdk-d6jjt-ae42ad0f67.json'
# Replace 'path/to/your/serviceAccountKey.json' with the actual path to your service account JSON file
cred = credentials.Certificate(key_path)
firebase_admin.initialize_app(cred)
@@ -10,11 +11,11 @@ def move_documents(source_collection):
db = firestore.client()
# Get all documents from the source collection
source_docs = db.collection(source_collection).get()
source_docs = db.collection(source_collection).where(filter=FieldFilter("name", "==", " S2-A-R1")).stream()
for doc in source_docs:
# Extract the document ID
doc_id = doc.id
print(doc_id)
# Get the document data
doc_data = doc.to_dict()