title: Firebase - How to create a new batch on the same batch reference
body: <p>I am using batches to migrate csv data to the firestore. The problem is that there is alot of data and the batch exceeds 500 ops limit so I have to commit current batch and make a new one in its place. Something like this:</p>
  <pre><code>function importRecord() {
     let records = [...]
     let batch = db.batch()
     for(let record in records) {
        createRecord(db, batch)
     }
     if(batch.ops.length !== 0) {
        batch.commit()
        batch = db.batch()
     }
  }
  
  function createRecord(db, batch) {
     if(batch.ops.length &gt;= 500) {
        batch.commit()
        batch = db.batch()
     }
     batch.update(...)
     ...
  }
  </code></pre>
  <p>Now when I create a new batch on the passed batch the batch in outer function loses reference.
  How do I go around this?</p>