> For the complete documentation index, see [llms.txt](https://estare.gitbook.io/firebase-auth-firestore-and-storage-plugin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://estare.gitbook.io/firebase-auth-firestore-and-storage-plugin/plugin-elements/data-schemas.md).

# Data Schemas

From v4.4.0, we have added to the plugin the possibility of linking "data types" do documents read from a [Firestore Data List](/firebase-auth-firestore-and-storage-plugin/plugin-elements/firestore-data-list.md), [Firestore Data Single](/firebase-auth-firestore-and-storage-plugin/plugin-elements/firestore-data-single.md) or [Firebase Auth (Current User)](/firebase-auth-firestore-and-storage-plugin/plugin-elements/firebase-auth-current-user.md) elements.

Since v4.5.0, [Firebase Data Extractor](/firebase-auth-firestore-and-storage-plugin/plugin-elements/firestore-data-extractor.md) and [Firebase Data Processor](/firebase-auth-firestore-and-storage-plugin/plugin-elements/firestore-data-processor.md) elements also receive the "data schema" option.

{% hint style="info" %}
You can see a sample of the "task manager" app using data schema on this editor -> <https://bubble.io/page?type=page&name=tasks-with-schema&id=estare-plugin-firestore&tab=tabs-1>
{% endhint %}

That mean you can define a type of "thing" on [Bubble's API Connector](https://manual.bubble.io/core-resources/api/the-api-connector) an use it to map the fields of your Firestore Documents, making the extraction of data from the document fields as easy as selecting a property in a Bubble "thing".

## Here is how to do it

1. Install the Bubble API Connector on your Bubble app

<div align="left"><figure><img src="/files/0GD8FHmaagI5VIJljAI0" alt=""><figcaption></figcaption></figure></div>

2. Click on "Add another API"

<div align="left"><figure><img src="/files/1sF63dujqfwp3GnIaaUQ" alt=""><figcaption></figcaption></figure></div>

3. Click on "Add another call"
4. Give the API Call the name you want your document type to have (e.g. "task"). Make sure the "Data type" of the call is "JSON".

<div align="left"><figure><img src="/files/J4q0fHSurMQYLXr9LjOE" alt=""><figcaption></figcaption></figure></div>

5. Click on the "Manually enter API response" option

<div align="left"><figure><img src="/files/ESdJuZ9ylvUoTXNLY6Dp" alt=""><figcaption></figcaption></figure></div>

7. Get a sample, in JSON, of the Firestore document you want to create a schema to, and paste it on the popup window.

{% hint style="info" %}
You can you our "[schema builder](https://estare-plugin-firestore.bubbleapps.io/version-test/schema-builder)" to turn the raw JSON string returned by [Firestore Data Single](/firebase-auth-firestore-and-storage-plugin/plugin-elements/firestore-data-single.md) elements into a "data schema" you can you on the API Connector.
{% endhint %}

<div align="left"><figure><img src="/files/rndMogvRDeeICXvSfyv5" alt=""><figcaption></figcaption></figure></div>

Hit "Save" and choose how you'd like each field to be treated from Bubble. For instance, as a text, number or date.

<div align="left"><figure><img src="/files/vIrZpp9yhYWXgCPGFeLt" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}
**Important!** Reference fields must be treated as texts. The plugin will always convert firestore reference objects into a path to the document (e.g. tasks/document\_id)
{% endhint %}

8. Now, on one of the supported element, you can define the "data schema" as "task"

<div align="left"><figure><img src="/files/rOXXJbe8dAF1gxTfjhff" alt=""><figcaption></figcaption></figure></div>

9. Then, you can access the document's fields from the "data (w/ schema)" state.

<div align="left"><figure><img src="/files/gKjWdSz4ysvlfeQGcvhi" alt=""><figcaption></figcaption></figure></div>
