Firebase How to update some children?

I have a parent with many children:

 Parent:{
        "childe1":"data",
        "childe2":"data",
        "childe3":"data",
        "childe4":"data",
        "childe5":"data"
 }

How can I update child items [ childe1 , childe2 , childe3 ]at the same time, preventing other users from updating them at the same time?

+4
source share
1 answer

To update multiple properties at the same time, you can run a call update():

ref.child("Parent").update({
  childe1: "newdata",
  childe2: "newdata",
  childe3: "newdata"
});

You can even specify paths as keys if the properties are at different levels of the tree. Even if it is not, the syntax will look like this:

ref.update({
  "Parent/childe1": "newdata",
  "Parent/childe2": "newdata",
  "Parent/childe3": "newdata"
});

, , .validate , , newData .

+7

Source: https://habr.com/ru/post/1662350/


All Articles