Skip to content

Instantly share code, notes, and snippets.

View santiagoaloi's full-sized avatar
:octocat:
Fall in Love with the Problem, Not the Solution.

Santiago A. santiagoaloi

:octocat:
Fall in Love with the Problem, Not the Solution.
View GitHub Profile
@gregfenton
gregfenton / firestore_add_field_to_all_docs_in_collection.js
Last active December 7, 2023 15:33
Updates all docs in a Firestore collection with the given values -- command-line JavaScript/node
/**
* firestore_add_field_to_all_docs_in_collection.js
*
* This script is assumed to live in an existing Javascript project that has its own package.json.
* I store this script in <PROJECT_ROOT>/tools/cleanup/.
*
* To use:
* 1. Import the 'firebase' and 'esm' NPM modules to your project (Run the command: `npm install firebase esm`)
* 2. Edit the data for USER1 and FIREBASE_CONFIG, then adjust parameters in `main` for the call to `visitDocs`.
*