Firestore

Read and write documents to Firebase Firestore

Overview

This node interacts with Firebase Firestore to perform various document operations such as deleting a document, retrieving a document, adding a document with an auto-generated ID, setting (creating or replacing) a document, updating (merging) a document, and querying a collection. It is useful for automating Firestore database management tasks within workflows, such as deleting obsolete records, fetching document data, or updating documents based on workflow logic.

Use Case Examples

  1. Deleting a user document by specifying its path to remove user data from Firestore.
  2. Retrieving a specific document's data to use in subsequent workflow steps.
  3. Adding a new order document to a collection with an auto-generated ID.
  4. Updating an existing document with new fields or merged data without overwriting the entire document.

Properties

Name Meaning
Document Path The path to the Firestore document to operate on, specified without a leading slash. Required for operations that target a specific document such as deleteDocument, getDocument, setDocument, and updateDocument.

Output

JSON

  • exists - Indicates if the document exists (boolean) when retrieving a document.
  • id - The document ID in Firestore.
  • path - The full path of the document in Firestore.
  • deleted - Indicates successful deletion of a document (boolean).
  • wrote - Indicates successful creation or replacement of a document (boolean).
  • merged - Indicates successful merging of data into a document (boolean).
  • data - The JSON data written to or merged into the document.
  • error - Error message if an operation fails and continueOnFail is enabled.

Dependencies

  • Firebase Admin SDK for Node.js

Troubleshooting

  • Missing or malformed Firestore credentials will cause initialization errors. Ensure the service account private key is correctly formatted and pasted exactly as provided by Google, with proper newline characters.
  • If a document path is incorrect or the document does not exist, getDocument will return exists: false.
  • Errors during Firestore operations will throw exceptions unless continueOnFail is enabled, in which case errors are returned in the output JSON under the error property.

Links

Discussion