1

I have an array in Firebase, which I'm getting like this:

var ref = new Firebase(url);
ref.orderByChild("date").on("child_added", function(obj) {
    console.log(obj.val());
});

But I need that in descending order. How can I do that with Firebase?

Thanks!

Ren P
  • 929
  • 9
  • 20
Matheus Lima
  • 2,103
  • 3
  • 31
  • 49
  • 1
    take a look here, see if it helps http://stackoverflow.com/questions/25611356/display-posts-in-descending-posted-order – Lucas Sep 11 '15 at 17:37

1 Answers1

0

Since you added the AngularJS tag, I'll assume you're using Angular in your project. In that case, it would make your life significantly easier to use AngularFire (http://angularfire.com).

Once you're using AngularFire, you can use the $firebaseArray service to grab your array from your database, and sort it just as you would any other array.

The $firebaseArray documentation can be found here: https://www.firebase.com/docs/web/libraries/angular/guide/synchronized-arrays.html

Wes Copeland
  • 361
  • 1
  • 9