Home > database >  How to update all values except one in Realtime Database?
How to update all values except one in Realtime Database?

Time:01-16

This is my node structure:
Database node
I want to change email, name and roll. For this, I have used map in java and used setvalue(map). But the problem is node extra is being deleted here. This node is used by cloud function, so I don't want to download the data and set the data while saving again.

Because:
Reason for not downloading
If the above step is completed before the below step, then I won't get the URL.
I don't want to touch the node extra and change other nodes at once. Is there any way to do so?

CodePudding user response:

How to update all values except one in Realtime Database?

Simply by using DatabaseReference#updateChildren(Map<String, Object> update) and passing a Map object that contains *only the fields you want to update. In this way, all the other fields will remain untouched.

DatabaseReference#setValue(Object value) will always overwrite the data at the specific location.

  •  Tags:  
  • Related