Firebase — Bulk delete child nodes

前端 未结 1 473
一生所求
一生所求 2020-12-03 17:15

I am building a simple todo app using reactFire, Firebase, and reactJS. The problem I am running into is when I try to bulk delete completed entries in the list.

         


        
相关标签:
1条回答
  • 2020-12-03 17:55

    You can delete all completed items in one go by using a multi-location update:

    var updates = {};
    for (var i in this.state.items) {
        var key = items[i]['.key'];
        if(items[i].done){
            updates[key] = null; // setting value to null deletes the key
        }
    }
    this.ref.update(updates);
    
    0 讨论(0)
提交回复
热议问题