amr abdulaziz amr abdulaziz - 1 year ago 106
Javascript Question

Firebase How to update multiple children?

I have parent with many children like this:


How can I update the children
[ childe1 , childe2 , childe3 ]
at same time, preventing any other user from updating them at same time?

Answer Source

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

  childe1: "newdata",
  childe2: "newdata",
  childe3: "newdata"

You can even specify paths as the keys, in case the properties are at different levels in the tree. Even though that doesn't seem to be the case here, the syntax would be:

  "Parent/childe1": "newdata",
  "Parent/childe2": "newdata",
  "Parent/childe3": "newdata"

The exact validation depends a bit on what you'd like to allow, but in general you'd write .validate rules on the server that validate that newData meet your requirements.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download