Here is how my structure looks like:
2017511
UcQefEaHJG6fteGsbsiaWjQ60d9Q62
value1: 50
value2: 1200
value3: "blabla"
AcQefEaHJG6fteGsbsiaWjQ60d9Q62
value1: 55
value2: 2200
value3: "balabla"
BcQefEaHJG6fteGsbsiaWjQ60d9Q62
value1: 20
value2: 500
value3: "blabala"
I am attempting to retrieve the value 3 of the top 10 highest value 2 entries. However, I encountered issues when new child nodes were added or values were changed.
$("#myList").html("");
firebase.database()
.ref('/2017511')
.limitToLast(2)
.orderByChild("value2")
.on("child_added", function(snapshot) {
console.log(snapshot.val().value3 + " "+ snapshot.val().value2);
$("#myList").prepend("<p>"+ snapshot.val().value2 + " "+ snapshot.val().value3 +"<p><br>");
})
I tried a different approach that initially worked fine, but upon running the function again, it duplicated the same values in each column...
function yenile(){
firebase.database().ref('/'+today).orderByChild("esita").limitToLast(1).once("child_added", function(snapshot) {
$("#bugun1").html(snapshot.val().username + " (" + (snapshot.val().esita).toFixed(0) + ")");
});
// More lines of similar code for different elements up to bugun10...
}