Firebase question: I'm trying to retrieve data back from a firebase database in order from greatest to smallest and then display it in the html. However, I haven't had any success. I know how to get the data back but I can't get it in order from greatest to smallest. Is this possible or do I have to sort the data when it comes back?
Here is the code I'm using.
``for (var x in allUsers) {
//db.ref('users/' + x).orderByChild('score').startAt(10000).on('value', snapshot => {
db.ref('users/' + x).orderByChild('score').endAt(9999).on('value', snapshot => {
//db.ref('users/' + x).on('value', snapshot => {
console.log( snapshot.val());
const newUserRow = $("<tr>");
const userName = $("<th> scope ='row'> ").html(snapshot.val().firstName);
const userLevel = $("<td>").html(snapshot.val().level);
const userPoints = $("<td>").html(snapshot.val().score);
newUserRow.append(userName)
.append(userLevel)
.append(userPoints);
$("#LeaderboardInformation").append(newUserRow);
});``
My thought process for this line of code is: 1) Retrieve from database 'users' 2) Get the 'score' key 3) Start where the score is '10000'.