This short script shows how to do a batched update of a very large data set in firestore.
The scenario is I have a large set of products, and a 'pool' of product codes that need to be assigned to them. This script loads the list of UPC codes from a firebase database, then updates a firestore collection, updating every doc with a UPC code. For each product, the next code docID is assigned (so it's reall a pointer to the code, not the code itself), then the code is updated to signify that is has been assigned.
The script pages through the product database 100 docs at a time, and assignes the update to a Promise array, then launches the array before recursing.
Keywords: recursion, batch updates, firebase, firestore