Support for multiple `OrderBy` queries.
See original GitHub issueI would like to see the ability to chain multiple OrderBy
queries to filter $firebaseArray.
An example is fleshed out here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase
Is this anywhere on the horizon for Firebase? My application sorely needs it.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:18 (6 by maintainers)
Top Results From Across the Web
SQL multiple column ordering - Stack Overflow
If you want to select records from a table but would like to see them sorted according to two columns, you can do...
Read more >Multiple orderby on query - WordPress.org
Hello, I can't do a multiple sort with the post date field and a custom field. If I use only one field, the...
Read more >How to Order By Two Columns in SQL? - LearnSQL.com
This query returns sorted records according to two columns: salary and last_name. ... After the ORDER BY keyword, add the name of the...
Read more >SQL Server ORDER BY clause By Practical Examples
This tutorial shows you how to use the SQL Server ORDER BY clause to sort the result set of a query by a...
Read more >Sort Multiple Columns in Queries - Visual Database Tools
To sort query results by more than one column · In the Criteria pane, click the Sort Order field for the column upon...
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
As discussed in the link you referenced:
This is a Firebase core issue, and has little to do with AngularFire.
Depending on your dataset, and what you are trying to do, this can be accomplished.
If there is NOT a lot of data - pull everything and just sort on the client
See angular’s orderBy filter.
If there IS a lot of data - create synthetic indexes yourself
On the client side, when you would normally do:
Note that I have done a couple things with the generated index values:
A. I’ve used
~
character as a separator, it is basically the last ASCII character. The goal here is thatjohn~doe
will still come afterjohny~appleseed
. If you are allowing users to store characters that are a superset of ASCII you will need to pick a different separator that is lexographically after whatever the highest allowed character is.B. I’ve lowercased everything in the indexes. Firebase process
orderBy
queries lexicographically, this leads to some unexpected results for the uninitiated:This has everything to do with the byte value of characters (an alphabetical sorting algorithm would be significantly more expensive).
C. I’ve padded leading
0
’s on the age. This allows users to be up to 999 years old. For bigger numbers you need more padding digits.As you can already tell, this quickly gets unmanageable if you need to be able to sort LOTS of different ways. You are also creating a bandwidth and storage penalty by creating those, so that needs to be weighed against the bandwidth penalty of option 1 above. This is similar to the exploding index problems you (used to?) run into on an AppEngine datastore. There are good talks on that topic that you should google if you are seriously considering this.
Other Thoughts
+1