title: Angular loop over Firestore data
body: <p>I have an Angular app using Firebase for hosting and Firestore for storing my data. I would like to create a function which reads all the data for a specific collection and loop over the documents to perform a certain action (upload to Google Drive, which has already been coded).</p>
  
  <p>However, I am struggling to loop over the documents in my Firestore collection. This is my code to read the data from my "test" collection in Firestore:</p>
  
  <pre><code>read() {
      let result = [];
  
      this.firestore
        .collection("test")
        .snapshotChanges()
        .subscribe(item =&gt; {
          item.map(row =&gt; {
            result.push(row.payload.doc.data());
          })
        })
  
      return result;
    }
  </code></pre>
  
  <p>In another component when I call this read() function and console.log it, I can see all data in the collection. However, when I try to loop over the documents and console.log them individually, it doesn't output anything. </p>
  
  <pre><code>async doSomething() {
      let allRows = await this.firebase.read();  // the function shown above
      console.log(allRows);  // I can see all the "rows"/documents in the collection
  
      allRows.forEach(item =&gt; console.log(item)); // but if I do this, it doesn't output anything
      console.log(allRows.length);  // even this outputs 0
  }
  </code></pre>
  
  <p>Am I missing something obvious?</p>