Can I move children from Firebase node in reverse order?

I am exploring the implementation of the in-firebase index as described here: https://stackoverflow.com/a/166268/ and trying to figure out how to deal with sorting data in descending order. Is it possible if you have a node with children 'a', 'b', 'c' to extract their 'c', 'b', 'a'? (although they can still get them in the original order?)

If it is not possible to move the node both forward and backward, and I need to create two indexes, is they a simple algorithm for generating keys that are sorted in reverse lexicographic order? For numbers, I think you can multiply by -1, but are not sure how to handle the strings ...

+6
source share
2 answers

It looks like you need a "reverse ()" query, similar to the way "limit ()" works. Firebase cannot do this yet, but we plan to add it.

Depending on your use case, it might be quite simple for you to get around this. If, for example, you use Firebase collation to save the list so that it is displayed to the user, you can simply change the display logic to display things back (for example, before adding items instead of adding). If you request a data window from a large set of children (for example, to get the first 10 items from a long list), the sort order should not be important - your starting and ending points for the query will remain the same, except that they will be canceled.

+9
source

Can you use limitToLast() and sort the result? I know this works if you use Angular, where items is a Firebase array object in $ scope;

 <li ng-repeat="item in items | orderBy:'-fieldName'"> {{ item.fildName }}</li> 
0
source

All Articles