go through an object and send the data to firebase

0

So far I have the following code, I get an object and with a for what I'm going through:

for (var i = 0; i < data.length; i++) {
          console.log("datos completos ->  " +  data[i].id_expediente);
         //acceder a mis datos de firebase
          this.db.collection("usuarios").doc(this.user.nombre_actuario)
                  .set({
                    [data[i].id_expediente] : JSON.stringify(data[i])
                  })
                  .then(function() {})
                  .catch(function(error) {
                    console.log(error);
                  });
        }

The problem is that only saves the last data in firebase, Any idea why the problem?

    
asked by Eze 26.06.2018 в 17:06
source

1 answer

1

I think the problem is that you're using set, what it does is erase everything in where you want to save and save what you're sending. Instead I think you should use push.

Or before sending you must assemble your object you want to send and then send it by set

    
answered by 26.06.2018 / 17:13
source