Angularfire: Join observables with many to many relation.

Created on 24 Oct 2016  路  1Comment  路  Source: angular/angularfire

I need to join the information of the tournament with the information about all the matches which are inside this tournament.
inside tournament I have the id's of the matches.

 10g8ha61v8j67mgx19uik3g89: true
 10sq64r1k6wdsr2j6s46ox0ix:  true

I am doing it like this, but the problem is that I want to have for the field tournament.upcoming FirebaseListObservables and not a simple array of FirebaseObjectsObservables.

    this.tournaments = this.af.database.list('https://something.firebaseio.com/soccer/tournaments')
        .map((_tournaments) => {
          return _tournaments.map((tournament) => {
            const self = this;
            if (tournament.matches.upcoming) {
              Object.keys(tournament.matches.upcoming).map(function (key, index) {
                if (!tournament.upcoming) {
                  tournament.upcoming = [];
                }
                if (key) {
                  if (index < 5) {
                    tournament.upcoming[key] = self.af.database.object(`https://something.firebaseio.com/soccer/matches/${key}`);
                  }
                }
              });
            }
            return tournament;
          })
        });

And in the client I want to be able to do something like this.

    <template [ngIf]="(tournaments | async)?.length">
        <ion-list-header class="main-heading"><strong>Upcoming</strong> games</ion-list-header>
        <ion-list *ngFor="let tournament of tournaments | async">
            <ion-item *ngFor="let match of tournament.upcoming"></ion-item>
       <ion-list>
</template>

Most helpful comment

Hi @alexandrzavalii!

We have a policy to close issues that do not follow the issue template. Feel free to create a new issue that follows the format.

>All comments

Hi @alexandrzavalii!

We have a policy to close issues that do not follow the issue template. Feel free to create a new issue that follows the format.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

harrylincoln picture harrylincoln  路  3Comments

cre8 picture cre8  路  3Comments

martinyoussef picture martinyoussef  路  3Comments

StephenFluin picture StephenFluin  路  3Comments

KLiFF2606 picture KLiFF2606  路  3Comments