def push_data(data, child: str): try: db.child(child.capitalize()).push(data) return 1 except: print(Handler.__name__ + ": something went wrong") return 0
def delete_character(child: str, name: str, userUID: str): try: database = db.child(child.capitalize()).get() for entity in database.each(): if (entity.val()['name'] == name and entity.val()['userUID'] == userUID): db.child(child.capitalize()).child(entity.key()).remove() return 1 except: print(Handler.__name__ + ": something went wrong") return 0
def delete_data(child: str, keyid: str): try: database = db.child(child.capitalize()).get() for entity in database.each(): print(entity.val()['keyid']) if (entity.val()['keyid'] == name.lower()): db.child(child.capitalize()).child(entity.key()).remove() return 1 except: print(Handler.__name__ + ": something went wrong") return 0
def update_data(data, child: str, name: str): try: database = db.child(child.capitalize()).get() for entity in database.each(): if (entity.val()['name'] == name.lower()): db.child(child.capitalize()).child( entity.key()).update(data) return 1 except: print(Handler.__name__ + ": something went wrong") return 0
def read_data(child: str): try: database = db.child(child).get() for entity in database.each(): print("\t" + entity.key() + " : ") print("\t" + str(entity.val())) except: print(Handler.__name__ + ": something went wrong") return 0
def get_data(child: str): items = [] try: database = db.child(child.capitalize()).get() for entity in database.each(): items.append(entity.val()) except: print(Handler.__name__ + ": something went wrong") return 0 return items
def get_data_in_list(child: str): data: list = [] try: database = db.child(child.capitalize()).get() for entity in database.each(): data.append( tuple(((entity.val()['name']), (entity.val()['name'])))) return data except: print(Handler.__name__ + ": something went wrong") return 0
def get_data_by_uid(request: str, child: str): items = [] uid = str(request.session['uid']) try: database = db.child(child.capitalize()).get() for entity in database.each(): if entity.val()['userUID'] == uid: items.append(entity.val()) except: print(Handler.__name__ + ": something went wrong") return 0 return items