Skip to main content

Firestore

Firestore is a highly durable database that can scale automatically to handle your application’s load.

Prerequisite

  1. Firebase Configuration Details: To connect with Firestore, gather the necessary configuration details from the Firebase console using these steps:

    • Access your Project settings.

    • Navigate to the Service accounts tab.

    • Click on the Firebase Admin SDK icon to generate a new private key.

    • Download the resulting JSON file and extract the Private key. This key is crucial for configuring the Firestore Connector.

      Obtaining details from Firebase Console
      Obtaining details from Firebase Console
  2. Optionally, Google Cloud Platform Account Key: If you prefer, you can create an account key through your Google Cloud Platform (GCP) console:

    • Choose a project in your GCP console.
    • Select Create Service Account and assign the Firebase Admin role.
    • Opt for a JSON Key type and download the resulting file. Ensure accessibility of this file for the connector's configuration.

Configuring Connector in DronaHQ

Configure your database category using the provided details. Validate connection with Test connection and Save settings for secure database setup.

General

FieldDescription
Firebase Database URLEnter the URL of your Firebase Realtime Database, e.g., https://your-project.firebaseio.com.
Private KeyPaste the contents of the Private Key obtained from the Firebase console or GCP console.
Firestore with Sample details.
Firestore with Sample details.

Admin

Advanced OptionDescription
Connection OptionsThe key and value connection options in database configuration refer to specific settings (keys) and their corresponding values that dictate how the application connects to the database
Whitelist IP Enhance security by restricting database access to specific whitelisted IP addresses.

Adding Queries for Firestore

Once you've successfully configured the Firestore connector, you can efficiently manage data-related operations, including the Update Document action. Follow these steps to create and execute queries:

  1. Define Query Name: Provide a unique name for your data management query. This name will serve as an identifier in your Connector Library for easy access and management.

  2. Select Action - Update Document: Within the Firestore connector options, choose the Update Document action. This action enables you to modify existing data entries within a specific document in your Firestore database.

  3. Choose Collection: After selecting the Update Document action, you'll have the option to choose the Firestore collection containing the document you want to update.

  4. Set Additional Parameters: Depending on your specific requirements, utilize optional parameters to refine the Update Document action. Customize the query by implementing filters, sorting criteria, or other pertinent options.

ParameterDescription
Order BySpecify the field for sorting the results in ascending or descending order.
Order DirectionDefine the sorting direction, either ascending or descending.
WhereFilter documents based on specified conditions.
LimitLimit the number of documents returned in the query results.
Start AtStart the query results at a specific document.
End AtEnd the query results at a specific document.
Document IDTarget a specific document by its unique identifier.
ValueProvide a specific value for query comparisons.
Parent Document IDReference the parent document ID for subcollection queries.

This table outlines the parameters you can utilize for performing queries and operations on your Firestore database, including ordering, filtering, limiting, and targeting specific documents.

  1. Test and Execute: Before finalizing the query, perform a test run to verify its functionality. Confirm that the document's data is correctly updated within your Firestore database.
Firestore connector update query
Firestore connector update query
tip

Utilize double curly brackets for incorporating dynamic variables. Prior to saving, test with sample values. Associate dynamic variables with controls/actions for real-time utilization. :::

Your saved queries will be visible beneath your connector within the Connector Library.

Supported Actions for Firestore

ActionDescription
Query FirestoreExecute a query to retrieve documents from a Firestore collection based on specified criteria.
Insert DocumentInsert a new document into a Firestore collection.
Update DocumentUpdate an existing document within a Firestore collection.
Get Document by IDRetrieve a document from a Firestore collection by its unique identifier.
Delete DocumentDelete a document from a Firestore collection.
Get CollectionsRetrieve a list of collections within a Firestore database.
Query Collection GroupsExecute a query to retrieve documents from multiple collections that share the same ID.

Using Firestore Connector

Insert Document

  1. Access Data Management Section or Control Action:

    • Begin by navigating to the data management section or the control action where you want to interact with your Firestore database.
  2. Select Firebase Firestore Connector:

    • Choose the Firebase Firestore Connector from your available options.

    • Opt for the "Insert Document" action to add new data to your Firestore collection.

    • Provide a Document ID if desired; otherwise, leave it blank for auto-generation.

    • Ensure that the data is in valid JSON format.

      Firestore Insert Document action
      Firestore Insert Document action
  3. Configuration for Data Input:

    • Configure the action by providing the necessary data in a valid JSON format.

    • This could involve collecting data from a form submission and adding it using the action.

      Firestore Form Example
      Firestore Form Example
  4. Execute the Action Flow:

    • Configure the Connector within the Action Flow or Server Side actions.
    • Link the action to a button click or relevant trigger.
    • When the form is submitted, the action flow triggers the Connector to save data to your Firestore collection.
  5. Confirmation and Display:

    • After the action is executed, use popup or toast actions to display relevant information, such as the created document ID.
    • You can also display the added data in a table grid or any other appropriate visualization.
Firestore Form Example