有一个对象,其中的用户呈数组形式,如何在不发送整个用户数组的情况下更新具有特定ID的用户。
const users = firebase.ref().child('users');
users.set(usersArray);
// data is stored in this form
{
users: [
{
id: userId,
...
},
{
id: userId,
...
}
]
...
}
同时更新不同用户的数据时,发送的数据将被覆盖,但有必要不覆盖
答案 0 :(得分:0)
您可以使用更新,也可以设置为true合并
set(
{a: {b: {c: true}}},
{merge: true}
)
With update you can also use field paths for updating nested values:
update({
'a.b.c': true
})