title: How to efficiently add items to collection with firebase firestore
body: <p>I have an array of tags that I would like to add to a firestore collection.</p>
  
  <p>If I'm not misunderstanding the approach I have here, I think I'm making individual adds to the collection when I think it would be more efficient to 'group' them and set them all at once. Is something like this possible? Also would it be possible to add the document to the workouts collection at the same time?</p>
  
  <p>Right now I'm looking at tags.length + 1 writes to firebase for every call to this function. I'd like to reduce that as much as possible.</p>
  
  <pre><code>logWorkoutAsync({ userId, timeStamp, tags }){
      var db = this.firebase.firestore();
  
      return db.collection('users').doc(userId).collection('workouts').add({
          timeStamp,
          'class': false
      }).then(doc =&gt; {
  
          var tagsCollection = doc.collection('tags')
  
          var promises = []
  
          tags.forEach(t =&gt; {
              promises.push(tagsCollection.doc(t.id.toString()).set(t))
          })
  
          return Promise.all(promises)
      })
  }
  </code></pre>