【问题标题】:angularfire2 database list multiple update at onceangularfire2数据库一次列出多个更新
【发布时间】:2018-01-20 13:07:34
【问题描述】:

我需要多次更新数据库列表,如下所示。

有没有比多次调用database.list('path/to/').update(key,value) 更有效的方法?对性能有影响吗?

这是我目前正在做的事情:

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);

【问题讨论】:

    标签: angular firebase ionic-framework firebase-realtime-database angularfire2


    【解决方案1】:

    您可以将ref ... update 与对象表示法一起使用来一次更新多个元素。前from the doc

    let newValues = {
      "userId": newNode,
      "worker_uid": newNode,
      "client_uid": newNode,
      "patient_uid": newNode,
    };
    
    firebase.database().ref('path/to').update(newValues);
    

    【讨论】:

    • 谢谢@Miam84,但我认为Angularfire2中没有那个选项
    • 发问者要求对 AngularFire2 而非 firebase JS sdk 进行多次更新。
    猜你喜欢
    • 2017-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-25
    • 2017-11-28
    • 1970-01-01
    相关资源
    最近更新 更多