I have a firebase realtime database. I would like to write a query and save the data to an array and work with later. Can I do it somehow? This code works nicely, just need to save it somehow for later. Object / map would be great, but an array works too. My half-code is here:
map = new Map();
var rootRef = firebase.database().ref("locations/map");
rootRef.once("value", function(snapshot) {
snapshot.forEach(function(child) {
console.log(child.key+": "+child.val().value);
map.set(child.key, child.val().value);
});
});
console.log(map);
It works fine, but if i try
console.log(map.get(0));
It's undefined. It's need to this for:
for (i = 0; i < someaarray.data.length; i++) {
if (someaarray.data[i].id == map.get(id))
{
someaarray.data[i].value = map.get(value);
}
}