Skip to content

Cloud Firestore#

Connection#

Insight² connects to your Cloud Firestore using JSON key of your GCP service account. To generate a new key, check out Firestore's official documentation.

Once the key is downloaded, click on + button of data sources panel at the left-bottom corner of the app editor. Select Firestore from the modal that pops up. Paste the key in the field for GCP key. Click on Test connection button to verify if the service account can access Firestore from Insight² server. Click on Save button to save the datasource.

Insight² - Data source - Firestore

Querying Firestore#

Click on + button of the query manager at the bottom panel of the editor and select the database added in the previous step as the data source.

Insight² - Data source - Firestore

Select the operation that you want to perform on Firestore and click Save to save the query.

Query results can be transformed using transformations. Read our transformations documentation to see how: link

Supported operations#

  1. Get document
  2. Query collection
  3. Add Document to Collection
  4. Update document
  5. Set document
  6. Bulk update using document id
  7. Delete document

Get document#

Use this operation to get the data in a document.

Required parameters:#

  • Path: Enter the path of the document. Path format: collection name/document id.
    Example: books/23e2wsds32

Insight² - Data source - Firestore

Query collection#

Use this operation to query all the documents in a collection. Check firestore doc here.

Required parameters:#

  • Path: Enter the name of the collection to be queried. Example: books

Optional parameters:#

  • Order type: Select ascending or descending from the dropdown.

  • Limit: Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. The Limit value should be of integer type.

  • Field, Operator, and Value: For filtering the results, you can enter a document field name, use appropriate operator from the dropdown and set a value.

Insight² - Data source - Firestore

Add Document to Collection#

Use this operation for creating a new document in a collection.

Required parameters:#

  • Collection: Enter the path of the document in a collection.
    Path format: collection name/document id. Example: books/33243dwe2332
  • Body: Enter the Field names and their values in json form. Example body:
    1
    2
    3
    4
    {
    "Author": "Shubh",
    "id": 5
    }
    

Insight² - Data source - Firestore

Update document#

Use this operation for updating the existing document in a collection. Also, it only updates fields if they exist, but doesn't replace an entire object like set opertion.

Required parameters:#

  • Path: Enter the path of the document in a collection.
    Path format: collection name/document id. Example: books/33243dwe2332
  • Body: Enter the Field names and their values in json form. Example body:
    1
    2
    3
    4
    {
    "Author": "Shubhendra",
    "id": 3
    }
    

Insight² - Data source - Firestore

Set document#

This operation replaces your chosen object with the value that you provide. So if your object has 5 fields, and you use Set operation and pass object with 3 fields, it will now have 3 fields.

Required parameters:#

  • Path: Enter the path of the document in a collection.
    Path format: collection name/document id. Example: books/33243dwe2332
  • Body: Enter the Field names and their values in json form. Example body:
    1
    2
    3
    4
    {
    "Author": "Shefewfbh",
    "id": 9
    }
    

Insight² - Data source - Firestore

Bulk update using document id#

Use this operation for bulk updating documents.

Required parameters:#

  • Collection:
  • Key for document ID:
  • Records:

Insight² - Data source - Firestore

Delete document#

Use this operation for deleting a document in a collection.

Required parameters:#

  • Path: Enter the path of the document to be deleted in a collection.
    Path format: collection name/document id. Example: books/33243dwe2332

Insight² - Data source - Firestore

Transforming firestore query result for Table widget#

The Firestore query result is in the form of object so we’ll need to transform it into array.

1
return data = Array(data)