title: Assign Incremental User ID Numbers in Firestore
body: <p>We have a vuejs project with a google firestore DB and we need to assign all of our users a unique File number. It has to be numeric, 6 digits, and start at 000052.</p>
  
  <p>We have approximately 4500 users.</p>
  
  <p>I would like to use google cloud functions. How can I assign this File number to every user that is incrementally greater for every user?</p>
  
  <p>I'm toying with trying to use firestore's limit query to find the previous user then increment the File # in the current user, etc., but that seems clunky.</p>
  
  <pre><code>db.collection('users').orderBy(id).get()
  .then((snapshot) =&gt; {
    snapshot.forEach(doc =&gt; {
      let last = snapshot.docs[snapshot.docs.length - 1];
      let next = db.collection('users')
      .startAfter(last.data().id)
      .limit(1)
      db.collection('users').doc(next.id).set({
        fileId: last.id++
      })
    })
  })
  </code></pre>