I’m working with Firebase Realtime Database and I want to update multiple properties under the same node using the update()
method. I’ve seen examples of using update()
to perform multiple updates on different nodes, but I want to clarify if it’s valid to use update()
on the same node. Here’s an example of what I have in mind:
const rootRef = ref.child('');
rootRef.update({
'users/gracehop/city': 'New York',
'users/gracehop/nickname': 'Amazing Grace',
'users/anotherUser/nickname': 'John Doe',
'customers/someId/role/admin': true,
'customers/IdForUserThatShouldBeDeleted': null,
});
In this example, I’m updating properties under the “users” node, specifically under the “gracehop” user. Is this a valid use of the update method, and will it work as intended?
Documentation: https://firebase.google.com/docs/database/admin/save-data#section-update