Descending query when using orderByChild()
See original GitHub issueHey there, @pautena and I are developing an Android app with a Firebase backend at Hack The North 2016.
We’ve faced this problem and we think that could be nice to solve with a new feature in future versions:
- When using the Firebase Realtime Database we were trying to get a DatabaseReference like this
mFirebaseDatabaseReference.child(User.USER_CHILD).orderByChild("points")
to make a ranking, but we faced the problem that Firebase only retrieves the ordered data in ascendent mode.
We think that would be awesome to have the possibility to query orderByChild with some kind of parameter which indicates if you want your data ordered in an ascendent or descendent way.
We post this issue to stay tuned for improvements in this area and hope Firebase become even more cool! 😄
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Sorting in descending order in Firebase database [duplicate]
If your data query is too large to sort client side you can do firebase.database().ref('books').orderByChild('ups').limitToLast(2).
Read more >how to implement descending orderByChild() - Google Groups
The trick to get descending order is to invert the number of likes, so: item. order = -1 * item.
Read more >Order and limit data with Cloud Firestore | Firebase - Google
By default, a query retrieves all documents that satisfy the query in ascending order by document ID. You can specify the sort order...
Read more >How to make a descending order in Firebase - YouTube
this.celebsDatabase = af.list('/Celebrity', { query : { orderByChild : "order", }});sendMultihypes(multihypes: number){ var holderhypes ...
Read more >Ordering and limiting Firestore queries in descending order
Explore further. For detailed documentation that includes this code sample, see the following: Order and limit data with Cloud Firestore · Ordering and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’ve found a good solution if you’re using the DatabaseReference to populate a FirebaseRecyclerAdapter, here it goes:
Hope it helps anybody with the same problem 😄
You can add it to onCreate