update( )

Write the enumerated children to this Firebase location. This will overwrite only children enumerated in the 'value' parameter and will leave others untouched. Note that the update function is equivalent to calling set() on the named children; it does not recursively update children if they are objects. Passing null as a value for a child is equivalent to calling remove( ) on that child.

The effect of the write will be visible immediately and the corresponding events ('value', 'child_added', etc.) will be triggered. Synchronization of the data to the Firebase servers will also be started, and if provided, the onComplete callback will be called asynchronously after synchronization has finished.

Note that modifying data with update( ) will cancel any pending transactions at that location, so extreme care should be taken if mixing update( ) and transaction( ) to modify the same data.

A single update( ) will generate a single 'value' event at the location where the update( ) was performed, regardless of how many children were modified.


update( value, [onComplete] )
value : An object containing the children and associated values to be written. onComplete (optional) : A callback function that will be called when synchronization to the Firebase servers has completed. The callback will be passed an Error object on failure, else null for success.


No return value.


var fredNameRef = new Firebase('https://SampleChat.firebaseIO-demo.com/users/fred/name');

// Modify the 'first' and 'last' children, but leave other data at fredNameRef unchanged
fredNameRef.update({first: 'Fred', last: 'Flintstone'});

// Same as the previous example, except we will also display an alert
// message when the data has finished synchronizing.
var onComplete = function(error) {
  if (error) alert('Synchronization failed.');
  else alert('Synchronization succeeded.');
fredNameRef.update({first: 'Wilma', last: 'Flintstone'}, onComplete);

var fredRef = new Firebase('https://SampleChat.firebaseIO-demo.com/users/fred');

//The following 2 function calls are equivalent
fredRef.update({name: {first: "Fred", last: "Flintstone"}});
fredRef.child("name").set({first: "Fred", last: "Flintstone"});