我正在使用Firebase实时数据库,我希望使用update()
方法更新同一 node 下的多个属性.我见过使用update()
在不同 node 上执行多个更新的示例,但我想澄清在同一 node 上使用update()
是否有效.下面是我脑海中的一个例子:
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,
});
在本例中,我更新了"users" node 下的属性,特别是"Uphop"用户下的属性.这是否是对update方法的有效使用,它是否会按预期工作?
文档:https://firebase.google.com/docs/database/admin/save-data#section-update