Firebase Auth, Firestore & Storage (plugin)
  • 🚀Getting Started
  • Setup
    • Create a Firebase Project
    • Get Firebase access credentials
    • Offline Support
    • Secure your credentials and data
      • Restrict your api-key to your domain
      • Security Rules on Firebase
  • Plugin Elements
    • 🛠️About elements
    • 💾Data Schemas
    • Firebase Auth (Current User)
    • Firestore Data List
      • Firebase Geohash
      • Firestore Data (legacy)
    • Firestore Data Extractor
    • Firestore Data Single
    • Firestore Data Aggregation
    • Firestore Data Processor
    • Firebase Storage Upload Button
    • Firebase Action Listener
    • Firebase Dropdown Processor
  • Plugin Front-end Actions
    • 💻About front-end actions
    • 💾Field types table
    • Firestore
      • Create a new document
      • Update a document
      • Delete a document
      • Update a list of documents
      • Delete a list of documents
      • Batch Operations
        • Batch Operation Constructor
        • Batch Operation Commit
    • Firebase Auth
      • Sign the User Up
      • Log the User In
      • Log the User In with Google
      • Log the User In with Facebook
      • Log the User In with GitHub
      • Log the User Out
      • Update User's Profile
      • Update User's Password
      • Update User's Email
      • Send password reset email
        • Handle reset password code
      • Send verification email
        • Handle verify email code
      • Delete current user
    • Firebase Storage
      • Upload file base64
      • Delete uploaded file
  • Plugin Back-end Actions
    • ☁️About backend actions
    • Firestore Backend
      • Get a list of documents
      • Get a single document
      • Count a list of documents
      • Create a new document
      • Update a document
      • Delete a document
      • Update a list of documents
      • Delete a list of documents
    • Firebase Auth Backend
      • Create an account for someone else
      • Update another user's profile info
      • Delete a user account
      • Generate email confirmation link
      • Generate password reset link
      • Set user roles
Powered by GitBook
On this page
  1. Plugin Front-end Actions
  2. Firestore

Batch Operations

PreviousDelete a list of documentsNextBatch Operation Constructor

Last updated 11 months ago

Batch operations in Firestore is a very useful feature to avoid inconsistencies on your data base. Basically, what they do is they set a bunch of operations to be executed, but try to do them all at once and, if any of them fails, none will be completed.

For instance, suppose we want to edit 3 documents that are related to each other in some way. Let's say a Charge document to be set as "paid", and the User balance to be incremented by 100. If I to the update on the Charge and the update on the User fails, there will be an inconsistency. The Charge will be computed as paid, but the User won't have received it new balance.

With batch operation we would create a new batch with the ID "process charge" and add 2 update operations to it:

  1. Update the status of a Charge to "paid".

  2. Update the balance of the User in 100.

We do that by using a action. Then we run a to try and do the 2 operations together. If either fails, none will be completed, maintaining consistency on the database.

Batch Operation Constructor
Batch Operation Commit