# How to: Create a Thing

A deep dive how we create new entries in the Database. To make sure everything happens smoothly let's go through a few things:

* Each query or table should have it's own Supabase Data element
* These Data elements have their own Element Actions so creating a new thing in a table, you should use the action which belongs to that Supabase Data element.&#x20;
* This needed because certain actions or functions are dependent on the Elements own properties which you setup initially, and when you refresh the query it's gonna take the initial query setup.&#x20;

Let's see a use case based on our Auth setup. Once a User has signed up, we want to create a new entry in our "user" table to track the user's metadata like First Name or Phone Number.&#x20;

See how the Auth part of this have been setup

{% content-ref url="../supabase-auth/how-to-sign-up" %}
[how-to-sign-up](https://docs.relevat.hu/supabase.js-bubble-plugin/setup/supabase-auth/how-to-sign-up)
{% endcontent-ref %}

And how the Database have been setup:

{% content-ref url="how-to-fetch-data" %}
[how-to-fetch-data](https://docs.relevat.hu/supabase.js-bubble-plugin/setup/supabase-data/how-to-fetch-data)
{% endcontent-ref %}

<figure><img src="https://565817280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmxSvZ04SZeWMqvozlHui%2Fuploads%2FkMf0PRRJj3chBnOuBKeR%2Fimage.png?alt=media&#x26;token=1866bf9c-4e31-4f8c-807e-1ad24f9e3bd1" alt=""><figcaption></figcaption></figure>

To make sure we have the data available we use the User Signed Up event. In the example we create a new entry for the user, where we attach the `auth.users.id` to the `created_by` column and the email address to the `email` field.&#x20;

Now what about Row Level Security? Since we've setup RLS based on the created\_by field which is not yet available for us yet, so how can we so the insert.&#x20;

You can do the API call server-side to bypass the RLS or with functions, or you can setup a simple RLS for just INSERT:

<figure><img src="https://565817280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmxSvZ04SZeWMqvozlHui%2Fuploads%2FvDgDr2c7lj3h1eq7pjII%2Fimage.png?alt=media&#x26;token=112af9dd-869a-4414-80e8-f50a41e96d30" alt=""><figcaption></figcaption></figure>

There's a field "Refresh Data" (true/false) this is a separate feature which allow better control. Here's the breakdown:

* Enable Realtime is true and Refresh Data is false: Data will be returned via Realtime.
* Enable Realtime is true and Refresh Data is true: Data will be returned via Realtime and not via the Refresh Data function
* Enable Realtime is false and Refresh Data is false: Query will not be refreshed

Once the entry have been successfully added you can reference that within the plugin's state "New Thing". That's why it's also important to use the related Supabase Data element for the action.&#x20;

Since Bubble is a bit unreliable with client side data retrieval, use a pause between the actions when referencing the state, or use the event "New Thing have been created".


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.relevat.hu/supabase.js-bubble-plugin/setup/supabase-data/how-to-create-a-thing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
