cred = credentials.ApplicationDefault()
firebase_admin.initialize_app(cred, {
'projectId': PROJECT_ID,
})
db = firestore.client()
def set_id(id: int):
''' create and update '''
path = 'xxxxxx'
db.document(path).set({
"id": id
})
def get_id():
''' get '''
path = 'xxxxxx'
db.document(path).get()
if data.exists:
return data.to_dict().get('id')
def get_ids():
''' get list '''
path = 'xxxxxx'
docs = db.collection(path).stream()
for doc in docs:
data = doc.to_dict()
......
def delete_id(id: int):
''' delete '''
path = 'xxxxxx'
doc = db.document(path).get()
if doc.exists:
db.document(path).delete()
Useful information