-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirebase_create_schema.py
36 lines (26 loc) · 1.1 KB
/
firebase_create_schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import firebase_admin
from firebase_admin import credentials, firestore
def main():
cred = credentials.Certificate("serviceAccountKey.json")
firebase_admin.initialize_app(cred)
firestore_db = firestore.client()
committees = ['HR', 'SC', 'OR', 'SF']
# committees = ['HR']
for committee in committees:
for i in range(1, 800):
idx = str(i)
while len(idx) < 3:
idx = "0" + idx
# firestore_db.collection(committee).document(idx).set({'recv_count': 0, 'recv_messages': [], 'sent_count': 0, 'sent_messages': []})
# firestore_db.collection(committee).document(u"EB").set({'recv_count': 0, 'recv_messages': [], 'sent_count': 0, 'sent_messages': []})
snapshots = list(firestore_db.collection(u"HR").get())
for snapshot in snapshots:
print(snapshot.to_dict())
if __name__ == "__main__":
print('This script deletes and resets all messages. Do you want to proceed "Yes, I am sure" / "No": ', end='')
opt = input()
if opt == "Yes, I am sure":
main()
else:
print('Aborting....')
pass