Firestore

Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.

Setup

To get started, add a project through the Firebase console and create a Firestore database:
https://firebase.google.com/docs/firestore/quickstart

Connect

You will need to use a Service Account in order to be able to access your Firestore via the Budibase connector.

To get the required credentials, within the Firebase console, click on the cog icon beside Project Overview and then select the Service accounts tab.

Next, click Generate new private key button. This will download a json file that will contain the credentials you need to connect.

In particular:

  • client_email
  • private_key
  • project_id

Whenever you add a new Firestore Data Source you will be prompted to enter these fields:

With your Firestore config saved, you will now be able to add a query.

Create query

  1. Select the 'Create' function
  2. Enter a collection to save the new document to
  3. Enter the JSON payload into the query box
  4. The newly created document will be returned with a randomly generated unique id

Bindings

You can also use bindings like so:

Read query

For these examples, there is a collection named test with five documents representing various fruit and veg.
Select the 'Read' function.

Get all documents from a collection

  1. Enter the name of the collection into the collection field
  2. Leave the filter fields blank

Using filter fields

These map to the parameters of the where clause

  1. Enter the field name: 'color'
  2. Select the 'equals' filter comparison
  3. Enter the filter value: 'yellow'

The full list of supported filter comparisons can be found here

Bindings

You can also use bindings like so:

Update query

Select the 'Update' function.

Update by id

  1. Enter the name of the collection into the collection field
  2. Leave the filter fields blank
  3. In the query box, enter the id to match on, and the field values to update to

Delete query

Select the 'Delete' function.

Delete by id

  1. Enter the name of the collection into the collection field
  2. Leave the filter fields blank
  3. In the query box, enter the id to match on

As with other data sources, you can Transform any query results.

For example, you may want to access the latitude and longitude from a GeoPoint

Sub-collection

To query a sub-collection simply provide the path within the Collection field

You can also use bindings within the collection path like so: