title: How to add a Firestore batch write method to this Google Apps Script library
body: <p>I want to write and send a pull request for a <a href="https://firebase.google.com/docs/firestore/manage-data/transactions#batched-writes" rel="nofollow noreferrer">Firestore batch write method</a> to the <a href="https://github.com/grahamearley/FirestoreGoogleAppsScript/blob/master/Firestore.js" rel="nofollow noreferrer">FirestoreGoogleAppsScript library</a>. The only problem is, I have no idea how to do that. So I need help getting started. The above link is the file where I think I should add the following.</p>
  
  <pre class="lang-js prettyprint-override"><code>/**
   * Create a batch write with the given fields and an auto-generated ID.
   *
   * @param {string} path the path where the document will be written
   * @param {object} fields the document's fields
   * @return {object} the Document object written to Firestore
   */
  this.batch = function (path, fields) {
    const request = new FirestoreRequest_(baseUrl, authToken)
    return createDocument_(path, fields, request)
  }
  </code></pre>
  
  <p>When finished, I would expect to call the function as follows.</p>
  
  <pre class="lang-js prettyprint-override"><code>// Get a new write batch
  let batch = db.batch();
  
  // Set the value of 'NYC'
  let nycRef = db.collection('cities').doc('NYC');
  batch.set(nycRef, {name: 'New York City'});
  
  // Update the population of 'SF'
  let sfRef = db.collection('cities').doc('SF');
  batch.update(sfRef, {population: 1000000});
  
  // Delete the city 'LA'
  let laRef = db.collection('cities').doc('LA');
  batch.delete(laRef);
  
  // Commit the batch
  return batch.commit().then(function () {
    // ...
  });
  </code></pre>
  
  <p>Is this the correct way to approach it or am I missing something?</p>