Having an issue with writing data to my Firebase realtime database. Below is the code I am using:
firebase.database().ref("ac/0/").set(null);
firebase.database().ref("ac/0/").once('value', function(snapshot){
for(var i=0; i<arr.length; i++){
firebase.database().ref("ac/0/"+snapshot.numChildren()).set({
"Current Date":arr[i][0],
"EmpNo":arr[i][1],
"Flag":arr[i][2],
"Prev Date":arr[i][3],
"Total charge":arr[i][4]
})
}
})
The expected behavior was for the data to be inserted into new incrementing nodes, but instead it keeps overwriting in the same node. Any insights on why this might be happening?