I never thought this would be an issue… But I found that this simple need to get data from a db in DESC order was not “out of the box” with Firebase.

One comment on a Github question on this subject worked for me.  It’s one line of code and it simply works… way better than other more complex solutions.

Basically, you take your Observable, such as the one below:

this.posts = this.af.database.list('/posts') as FirebaseListObservable<Post[]>;

You can modify it with a map that runs a reverse method on it:

this.posts = this.af.database.list('/posts').map( (arr) => {return arr.reverse();}) as FirebaseListObservable<Post[]>;



No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *