0

I need to update a database list multiple times as shown below.

Is there a more efficient way than calling database.list('path/to/').update(key,value) multiple times? Does it have an effect on the performance?

This is what I'm currently doing:

var newNode = {};
newNode[appointmentUid] = true;

this.database.list('/appointment/users').update(userId, newNode);
this.database.list('/appointment/users').update(worker_uid, newNode);
this.database.list('/appointment/users').update(client_uid, newNode);
this.database.list('/appointment/users').update(patient_uid, newNode);

1 Answer 1

1

you can use ref ... update with the object notation to update multiple elements at once. Ex from the doc :

let newValues = {
  "userId": newNode,
  "worker_uid": newNode,
  "client_uid": newNode,
  "patient_uid": newNode,
};

firebase.database().ref('path/to').update(newValues);
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @Miam84, but I think there is not that option in Angularfire2
The questioner has asked multiple updates for AngularFire2 and not the firebase JS sdk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.