You're viewing the legacy docs. They are deprecated as of May 18, 2016.
These docs are for version 2.4.2 and below of the Javascript SDK. Go to our current docs, or see our Web migration guide.

Version 2.4.2Changelog


Write the enumerated children to this database 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.

var fredNameRef = new Firebase('');

// 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) {
    console.log('Synchronization failed');
  } else {
    console.log('Synchronization succeeded');

fredNameRef.update({ first: 'Wilma', last: 'Flintstone' }, onComplete);
var fredRef = new Firebase('');

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