- My Sample Data
Code
let users_ref = firebase_instance.database().ref('users'); let amount_of_data = 4; let limit_users_ref = users_ref.orderByChild("score").limitToLast(amount_of_data); limit_users_ref.once('value', function(snapshot) { snapshot.forEach(function(childSnapshot) { var childKey = childSnapshot.key; var childData = childSnapshot.val(); console.log([childKey, childData]); }); })
Output I am getting
As it can be seen on output, the data is not ordered. I should be getting test1 in stead of test3 there. Anything I am doing wrong?