Firebase Admin icon

Firebase Admin

Interact with Firebase Firestore, Auth, and Storage using Firebase Admin SDK

Firestore → Transaction

AI-generated

Summary

Execute multiple Firestore operations atomically within a transaction, supporting reads, writes, validation, and custom JavaScript code computations with automatic retry on conflicts.

Inputs

  • Project Name or ID — Select the Firebase project from the list or provide its ID via expression.
  • Transaction Operations (required) — Define a sequence of operations to execute within the transaction, including reads (Get), writes (Create, Set, Update, Delete), validations, and custom code execution. Each operation requires specifying the operation type and relevant parameters; for document operations, provide the full document path and optionally JSON data. Reads must precede writes.

Output shape

a list containing the results of each transaction operation executed in order

The output includes the data returned by read operations and any results from custom code execution. If a validation fails, the transaction stops and returns an error with the provided message. Transactions automatically retry on conflicts.

Examples

Example 1: Increase a user's score if they have sufficient balance

Define a transaction with a 'Get' operation to read the user document, a 'Validate' operation ensuring the balance is sufficient, and an 'Update' operation to increment the score.

Links

Discussion