Batch Operation Constructor

This action sets a create, update or delete event to happen on a document, but doesn't execute it until you call a "Batch operation commit" action. This is useful when you want to edit a bunch of documents only if all operation are a success.


Inputs and Settings

Batch ID

The ID or name you want to give to your batch operation. All operations you add to it must have the same ID, so they can be linked together.

Operation Type

Defines the type of operation you want to add to the batch. You can add more than one type of operation to the same batch.

Types:

  • Create

  • Update

  • Delete

Trigger ID (optional)

This will link the action with a Action Listener of the same ID.

If left blank, all listener on the page with blank ID's will be triggered at the same time, so we suggest to always define a Trigger ID.

If something goes wrong while adding the operation to the batch, it will trigger and error event.

Collection

The name or ID of the collection that contains the document you want to create, update or delete.

Doc ID (optional)

The ID of the document you want to create, update or delete.

Since batch operation don't create Firestore Documents IDs automatically, you must provide one. But if you type "auto" on the "doc ID" field, we'll run a crypto.randomUUID() javascript function to generate one for you.

Merge if document exists

In operation of type "Create", if there is already a document on the collection with the same ID, this option defines how it will handle this conflicting data.

  • If checked, the action will behave as an "update" operation on the existing document.

  • If unchecked, the action will overwrite the existing document, deleting all fields you didn't specify.

Fields

When you "create" or "update" a document, you must inform which fields and which content each will have on it's structure, in JSON format. This input allows you to set as many fields as you want.

For each field you must specify the "key" and the "value" that will be stored, the same way as in other database operations, like, for instance, "Create a new document".

Field Types

For each key/value pair you define and provide a value on the Fields list, you must provide the same key, but with the type of the value, on the Field Types input. That allows the plugin to turn the texts being fed into the plugin into corresponding values on the JSON structure sent to Firestore.

If the number of Fields and Field Types don't match, the action will result in an error.

See the field types table to see which types are currently supported by the plugin and how to define them.


Triggered events

Those events are triggered by an Action Listener with the same ID as the Trigger ID provided on the action.

  • Error in Action (if an error occurs)


Stored values on the listener

New Document ID

The ID of the document created by the action.

Error Message

If an error occurs, you can check its details on this state on the action listener.

Last updated