title: Firebase join without subscription
body: <p>I need to join two tables in Firebase Firestore DB. Do do so, I have to get a value from collection 'attendees' and then perform a <code>forEach</code> to recover the event data in collection 'event', pushing it into an array and then return the array in a promise.</p>
  
  <p>I am using <code>.valueChanges().subscribe()</code>. What happens here is, if I add a new event for this attendee, the subscription works and push the data into the array again.</p>
  
  <p>What I need to know, is how with join table work. Is there any way to perform the forEach with no subscription?</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is my collection combination to perform the join</p>
  
  <pre><code>findByUserUid(user_uid: string) {
      let events: any[] = [];
      console.log(events);
  
      return new Promise((resolve, reject) =&gt; {
        console.log(events);
  
        this.db
          .collection('attendees', ref =&gt; ref.where('user_uid', '==', user_uid))
          .snapshotChanges()
          .subscribe((attendeesSnaps: any) =&gt; {
            events = [];
            attendeesSnaps.forEach((attendeeSnapshot: any) =&gt; {
              this.db
                .collection('events')
                .doc(attendeeSnapshot.payload.doc.data().event_uid)
                .valueChanges()
                .subscribe((event: any) =&gt; {
                  console.log(events);
                  event.uid = attendeeSnapshot.payload.doc.data().event_uid;
                  events.push(event);
                  console.log('pushing', event);
                });
            });
          });
        console.log('all events', events);
  
        resolve(events);
      });
    }
  </code></pre>
  
  <p>When collection 'attendees' is updated (adding a new attendee to -this- event), the foreach is perfom again and I got duplicate data in <code>events</code> array (which is returned again because of the subscription).</p>
  
  <p>I need to avoid this duplicate data to be returned in every collection update.</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>I've fixed the issue. Using <code>.ref.get()</code> works fine! Here is my final version of the method (if it can be improved, please let me know :) )</p>
  
  <pre><code>findByUserUid(user_uid: string) {
      const events: any[] = [];
  
      return new Promise((resolve, reject) =&gt; {
        this.db
          .collection('attendees')
          .ref.where('user_uid', '==', user_uid)
          .get()
          .then((attendeesSnaps: any) =&gt; {
            attendeesSnaps.forEach((attendeeSnapshot: any) =&gt; {
              this.db
                .collection('events')
                .doc(attendeeSnapshot.data().event_uid)
                .ref.get()
                .then((eventSnap: any) =&gt; {
                  const event = eventSnap.data();
                  event.uid = eventSnap.id;
                  events.push(event);
                })
                .catch(err =&gt; {
                  reject(err);
                });
            });
          })
          .catch(err =&gt; {
            reject(err);
          });
        resolve(events);
      });
    }
  </code></pre>