firestore-batch-incrementer

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2025 License: MIT Imports: 12 Imported by: 0

README

GitHub release License Active

firestore-batch-incrementer

Iterates through a Firestore collection in batches and atomically increments a specified root‑level numeric field with configurable rate limiting.

Purpose

Loops through every document in a specified Firestore collection and atomically increments a given root‑level numeric field—adding the field with a count of 1 if it doesn’t exist—to bulk-update all records so that downstream Eventarc triggers fire on each change.

This application runs scanning through the collection, updating each document at the specified rate limit, and then exits. It is intended to run as a Cloud Run Job.

Environment Variables

  • PROJECT_ID – GCP project ID
  • COLLECTION – Firestore collection to scan
  • FIELD_KEY – Root‑level field to increment
  • DATABASE_ID – Firestore database ID (default: "(default)")
  • BATCH_SIZE – Number of documents per batch (default: 100)
  • RATE_LIMIT – Maximum updates per second (default: 50)
  • ATOMIC_UPDATES – Use atomic transactions for updates (ensures document existence, default: false)
  • UPDATE_TYPE – Defines how the field is updated. Possible values:
    • INCREMENT (default): Atomically increments the numeric field by 1.
    • START_TIMESTAMP: Sets the field to the same UTC timestamp captured at the start of execution.
    • CURRENT_TIMESTAMP: Sets the field to the current UTC timestamp for each document as it is updated.
  • GOOGLE_APPLICATION_CREDENTIALS – (Optional) Path to the service account JSON file. If not set, Application Default Credentials (ADC) will be used (e.g., when running in Cloud Run Jobs with an attached service account).

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL