I need to remove only part of data in user section by key
ref = db.reference(user.uid)
user_data = ref.get()
reqs = user_data['support_req']
for req in reqs:
print(req)
print(user_data['support_req'][req])
result:
-NQKyF9j6Fcnd4aeQyW5
{'telephone': '+000000000000'}
I need to remove key and value from database
If you want to delete all the RTDB nodes under the support_req
node, the following should do the trick (untested):
support_req_ref = db.reference(user.uid + '/support_req')
support_req_ref.delete()
If you want to delete a specific sub-node of the user's support_req
node you need to know its id, e.g. -NQKyF9j6Fcnd4aeQyW5
in your example. Then you should do:
support_req_ref = db.reference(user.uid + '/support_req/-NQKyF9j6Fcnd4aeQyW5')
support_req_ref.delete()