Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import firebase_admin
- from firebase_admin import credentials
- from firebase_admin import firestore
- import traceback
- import json
- cred = credentials.Certificate(constants.path_to_json)
- default_app = firebase_admin.initialize_app(cred)
- other_app = firebase_admin.initialize_app(cred, name='other')
- db = firestore.client()
- match_id = 'blala'
- pool_id = 'pidxyz'
- cont_team_id = '229'
- doc_ref = db.collection('match-pools')
- .document(match_id)
- .collection('pid')
- .document(pool_id)
- .collection('contestant-teams')
- .document(cont_team_id)
- def create_counter(ref, num_shards):
- batch = db.batch()
- print(batch)
- # Initialize the counter document
- batch.set(ref, { num_shards: num_shards })
- # Initialize each shard with count=0
- for i in range(0, num_shards):
- shardRef = ref.collection('shards').doc(i.to_string())
- batch.set(shardRef, { count: 0 })
- # Commit the write batch
- return batch.commit()
- create_counter(doc_ref, 5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement