0
votes

I am trying to query the firebase realtime database with Angular 5 ()

I have tried the new API but I am getting nowhere with Querying the real time database, the query runs but I get no results.

My data set is simple Data structure

I can list all of the data without issue, but when I try and query results filtering on a field I get the two console log events, but empty data?? Any ideas??

I am using the following versions "@angular/cli": "1.6.3", "@angular/compiler-cli": "^5.0.0", "@angular/language-service": "^5.0.0", "angularfire2": "^5.0.0-rc.4", "firebase": "4.8.0",

   find(abn: string) {
      this.db.list<company>('/company', ref => ref.orderByChild('abn').equalTo(abn)).snapshotChanges().map(actions => {
         console.log(`Action: ${actions}`);
         return actions.map(action => ({ key: action.key, value: action.payload.val()}));
      }).subscribe(items => {
        this.query = items.map(item => ({key: item.key, value: item.value}));
        console.log(`Query Results: ${this.query}`);
      });
    }
1

1 Answers

0
votes

So I figured out the mistake, the real time database actually types data. The abn field is a number and I was passing a string to the query. Changing it to a number works.