So I am trying to retrieve a list of players scores in order. I am using a query with Firebase list observable, It works, but it starts at 0 and goes up. Instead, I want to start with the largest on down.
I tried using -score
but that did not work either.
Code:
this.PlayerList=this.AngularFire.database.list(`/Rooms/PList`, {
query:{
orderByChild:'score',
}
});
You can't set the order direction in Firebase. The options are to sort locally, which is not much use if you are paging or to create a child property to sort on. So for your case you could keep have a scoreOrder property with the value always set to the negative score and then sort on that to get the results to return with the highest scorer first.
See this link for more details https://groups.google.com/forum/#!topic/firebase-talk/nigfh-ekIm8