2

I've Table "A" with an array inside that contain 0 to N key of table "B" my intent is to use swtich map for get all the record of table "B".

until i've 1 to 1 key i've implement this simple function :

`

           // Combine Object
           let TableATableB = TableB

                 // Per ogni Ordine eseguo una SwitchMap
                 .switchMap(Ordini => {

                   // Puntando all'evento tramite la chiave :
                   const Scuola = Ordini.map( Ordine => this.db.object(`users/${Ordine.IDScuola}`) );

                   // Se l'oggetto esiste combino i dati e li restituisco

                   return Scuola.length === 0 ?
                     Observable.of(Ordini) :
                     Observable.combineLatest(...Scuola, (...scuole) => {
                       Ordini.forEach((Ordini, index) => {
                         Ordini.DatiScuola = scuole[index] ;
                     });
                     return Ordini;
                   }
                 );
                 });

`

But how can i implement this when "Ordine.IDScuola" is an array of key and not a single Element?

0 Answers0