Luis Alvarez
Luis Alvarez

Reputation: 99

AngularFire how I can update all values

How I can to put on the table all values contabilidad (pago) to 0, all the same time not one by one? enter image description here

Upvotes: 0

Views: 679

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598648

Firebase recently introduced the ability to update multiple locations with one update() call.

ref.child('contabilidad').once('value', function(snapshot) {
  var updates = {};
  snapshot.forEach(function(child) {
    updates[child.key()+'/pago'] = 0;
  });
  ref.child('contabilidad').update(updates);
});

Also see this blog post on how to use this feature for atomic client-side fan-out.

Upvotes: 4

Related Questions