Firebase Auth, Firestore & Storage (plugin)
  • 🚀Getting Started
  • Setup
    • Create a Firebase Project
    • Get Firebase access credentials
    • Offline Support
    • Secure your credentials and data
      • Restrict your api-key to your domain
      • Security Rules on Firebase
  • Plugin Elements
    • 🛠️About elements
    • 💾Data Schemas
    • Firebase Auth (Current User)
    • Firestore Data List
      • Firebase Geohash
      • Firestore Data (legacy)
    • Firestore Data Extractor
    • Firestore Data Single
    • Firestore Data Aggregation
    • Firestore Data Processor
    • Firebase Storage Upload Button
    • Firebase Action Listener
    • Firebase Dropdown Processor
  • Plugin Front-end Actions
    • 💻About front-end actions
    • 💾Field types table
    • Firestore
      • Create a new document
      • Update a document
      • Delete a document
      • Update a list of documents
      • Delete a list of documents
      • Batch Operations
        • Batch Operation Constructor
        • Batch Operation Commit
    • Firebase Auth
      • Sign the User Up
      • Log the User In
      • Log the User In with Google
      • Log the User In with Facebook
      • Log the User In with GitHub
      • Log the User Out
      • Update User's Profile
      • Update User's Password
      • Update User's Email
      • Send password reset email
        • Handle reset password code
      • Send verification email
        • Handle verify email code
      • Delete current user
    • Firebase Storage
      • Upload file base64
      • Delete uploaded file
  • Plugin Back-end Actions
    • ☁️About backend actions
    • Firestore Backend
      • Get a list of documents
      • Get a single document
      • Count a list of documents
      • Create a new document
      • Update a document
      • Delete a document
      • Update a list of documents
      • Delete a list of documents
    • Firebase Auth Backend
      • Create an account for someone else
      • Update another user's profile info
      • Delete a user account
      • Generate email confirmation link
      • Generate password reset link
      • Set user roles
Powered by GitBook
On this page
  • Settings
  • Firestore Collection
  • Doc ID
  • Make query static
  • Fields (1, 2, 3, ...)
  • Field List (1, 2, 3, ...)
  • Field Types (1, 2, 3, ...)
  • States and Values
  • Data
  • Data (w/ schema)
  • Document ID
  • Collection
  • Error message
  • Field (1, 2, 3, ...)
  • Field List (1, 2, 3, ...)
  • Data is Ready
  • Events
  • Data ready or changed
  • Using query results as inputs in other queries
  1. Plugin Elements

Firestore Data Single

PreviousFirestore Data ExtractorNextFirestore Data Aggregation

Last updated 11 months ago

The Firestore Data Single element combines the behavior of the and elements.

As it is very common to get a single document from the database, instead of using a Data Element + Extractor Element to get the document's fields, you can simply use the Firestore Data Single.


Settings

Firestore Collection

Here you must specify the id (or name) of the collection you want to query data from. You can subcollections paths to choose a subcollection (e.g. collection/doc_id/subcollection).

The plugin will query data from the Firestore, running front-end process on Bubble. That way, no Workload units will be consumed. 🙂

Doc ID

The ID of the document you want to get from Firestore.

Make query static

If checked, document data won't update dynamically or react to changes on the database.

Fields (1, 2, 3, ...)

The name or path (in dot notation) of the field you want to extract from the document.

For instance, if you you want to extract the content of the field "description" on the document, that's the name you should put on this setting.

If the field is of type Map, you can use "dot notation" to extract the value of a specific key on the map. In the example below, a field of name "links" has two keys, "pt-br" and "en-us". To get the value from the "pt-br", the Field would be "links.pt-br".

If you don't specify a path and only provide "links" as a path, the entire Map JSON structure can be used as a text. This JSON text can be used in another Data Extractor to get specific fields from it too.

Field List (1, 2, 3, ...)

The name of the array/list field you want to extract from the document. The generated state will be turned into a Bubble list of values.

Field Types (1, 2, 3, ...)

Choose between the Bubble's basic data types, so that the value of the Field you're extracting can be translated to it. This can end up in error's, like if you try to provide a text to a field you defined as number, so be careful with what you choose and check your browser's console (press "F12") to look for errors.

Some data types on Firestore must be treated as texts on Bubble if you want to display them or use them elsewhere, like "Maps" or "References".

"Reference" types will be displayed as a text showing the path to the document, like so: collection_name/document_id

(e.g. tasks/6KXLqGVsvGdytOI5pB8F or users/6n6tlWXTDwUp3f7yQ95mpITUUmZ2)


States and Values

For each field you get from the document, there is a corresponding state containing it's value, along with some other useful data.

Data

The JSON structure of the document. It can be used in a Firestore Data Extractor element, to get more fields than those available on this element. Or you could use it to pass along the document data to another element or page in your application.

Keep in mind that this document data is not dynamic, which means that if you pass it to another element or a Custom State, for instance, this data won't react to changes in the database, even if they come from a dynamic query.

Data (w/ schema)

Document ID

The ID of the processed document. This ID is available in the JSON structure under the key "_id", but is extracted by default.

Collection

The collection of the processed document.

Error message

Stores the last error message on the element, if there was any.

Field (1, 2, 3, ...)

The value extracted from the field, translated to the Field Type you defined for it.

Field List (1, 2, 3, ...)

A list of values extracted from an array field on the document, each entry translated to the Field Type you defined for it.

Data is Ready

Turns to "yes" when all the element's states are done being filled, an "no" when they are being filled.

Although this operations are fast, the fact the they are filled in order and not at the same time may lead to issues, that's why this state was created.


Events

Data ready or changed

This event is triggered when the document is ready or any changes come from the database.


Using query results as inputs in other queries

Keep in mind that, bacause the query operations run on the front-end, Bubble sometimes messes with the order in which data arrives from Firestore. That means you must account that factor while using results of other Firebase elements as input data in other query elements.

For instance, if you want to get documents form the "tasks" collection where the "owner" filter equals the current user's document reference, you can use the filter bellow (owner == users/Firebase Auth's User ID).

But if the User ID is not yet available, the query will fail due to security rules on Firestore.

To work around that, you can put a visibility conditional on the Firestore Data element, for it to show only when the User ID is not empty. As the query will only occur when the element is "visible" on the page, it will wait for when the User ID is available to run the query, avoiding the error.

Keep that in mind when fetching data from Firestore.

If the list is a list of "Map" types, you can feed them to a , to treat them as a list of documents and extract data further.

The Firestore Data Single element provides similar states to those from the and elements.

The JSON data, interpreted through the "data schema" you define on an API Connector and provide to the element. See how to configure this on the documentation.

Firestore Data Processor
Data
Data Extractor
Data Schemas
Firestore Data
Firestore Data Extractor