25416

Android Firebase multiple sort

Question:

I have a question about firebase sorting.

I have the next database:

{ "-Ka8xxTgyFB8yYKH50j_addclose" : { "number" : 0, "point" : 949739, "timestamp" : 14824078463440, "username" : "Test 16062" }, "-Ka8xzKecpbPr46Kx9gl" : { "number" : 0, "point" : 1480851, "timestamp" : 14842078463441, "username" : "Test 13599" } }

I want to display data sorted by point. But i need rows only which created today.

If i filter the rows for timestamp:

return databaseReference .child("list") .orderByChild("timestamp") .endAt(end.getTime());

The endAt is work good. Only todays rows listed. But... Now i need to sort by point.

How can i do it?

There is any idea to change database or sort my list on clientside?

Thanks so much!

Answer1:

You'll need to sort all your data client side as there can only be one orderBy column per query.

If you need to double sort server side you'll have to update your database to have a combined key that would hold both timestamp and point.

Recommend

  • How to retrieve data from firebase to google map?
  • Firebase always returning all the rows
  • Listen to multiple database references [duplicate]
  • Update Marker when Location Change based on Value of Child Firebase Android
  • How to mock current date?
  • Get count of created entries for each day
  • Python find continuous interesctions of intervals
  • Copying rows in a database when rows have children
  • Passing information to server-side function in a Google Docs Add On
  • Send emails through VB6 if no email client
  • How to turn (A, B, C) into (AB, AC, BC) with Pig?
  • Why doesnt this Java loop in a thread work?
  • Check for zero lines output from command over SSH
  • Not able to aggregate on nested fields in elasticsearch
  • Sort List of Strings By Version
  • How to suppress a dialog
  • Xamarin Forms - UWP Fonts
  • Spring security and special characters
  • Incrementing object id automatically JS constructor (static method and variable)
  • vba code to select only visible cells in specific column except heading
  • ActionScript 2 vs ActionScript 3 performance
  • To display the title for the current loaction in map in iphone
  • Do I've to free mysql result after storing it?
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • retrieve vertices with no linked edge in arangodb
  • Free memory of cv::Mat loaded using FileStorage API
  • How to set the response of a form post action to a iframe source?
  • How do I configure my settings file to work with unit tests?
  • embed rChart in Markdown
  • Turn off referential integrity in Derby? is it possible?
  • Linking SubReports Without LinkChild/LinkMaster
  • Add sale price programmatically to product variations
  • unknown Exception android
  • Sorting a 2D array using the second column C++
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app
  • Python/Django TangoWithDjango Models and Databases
  • How do I use LINQ to get all the Items that have a particular SubItem?