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
@santiagoaloi
santiagoaloi / firestore_add_field_to_all_docs_in_collection.js
Created April 24, 2022 19:54 — forked from gregfenton/firestore_add_field_to_all_docs_in_collection.js
FIRESTORE: a node/JavaScript command-line script that visits all docs in a Firestore collection and updates them with the given values (in this example, we set/add an "enabled" field to TRUE) -- uses the Firebase Web SDK v9 API
/**
* 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`.
*