Home > Back-end >  Why orderByChild does not sort in AngularFire for Realtime database?
Why orderByChild does not sort in AngularFire for Realtime database?

Time:12-10

I'm trying to order an acccount list using orderByChild using dateCreated field, but the return list(response) is not sorted by dateCreated

 this.angularDb.list('accounts', ref => ref
        .orderByChild('dateCreated').startAt(0).limitToFirst(10)
        ).valueChanges()
        .subscribe(response => {
            for (let item of response) {
              this.tableData.push(item);
            }
     
         }, error => {
            console.log(error);
         });
    
  }

Any idea what I'm doing wrong? I cannot find any source solve this issue

CodePudding user response:

I found the answer which is that firebase does not support sorting dates: https://firebase.google.com/docs/database/web/lists-of-data#data-order

  • Related