Skip to main content

Creating, saving and deleting data

This article covers how to work with the data in your database by creating, changing and deleting things

Written by Sofia Maconi

Bubble comes with a range of ways to work with the data in your database:

  • Create new things

  • Make changes to existing things

  • Delete things

You can manipulate data in the database in three different ways:

Workflows

A workflow is a collection of actions that run in sequence whenever an event happens. You can choose from many different types of events, such as a button click, an input field being updated, or a specific condition becoming true.

Actions

A few different actions make changes to the database. Click the links below to see the core reference entry for each one:

By combining these actions in different ways, you can work with new and existing data flexibly, and add other actions, related or unrelated to the database, alongside them.

Example

Say you've set up a form that lets a user edit their own profile. You'd have a few input fields where the user can provide information, and a button that triggers the workflow.

With this setup, no changes are saved to the database until the user clicks the button.

Some information, like email and password, has to be changed using a different action from Make changes to a thing. Because of the sensitive nature of user credentials, they need to be handled differently to protect their security and the user's privacy.

Article: User accounts

Workflows let you add further actions after the first one, to perform other relevant tasks. For example, you could use the alert element to display a message once the operation succeeds:

As this example shows, workflows are useful when you want the user to decide when to save changes, or when you need to chain more than one action together.

Auto-binding

Auto-binding is only available in web apps.

Auto-binding means binding an input element to a specific field on a data type. Once this is set up, Bubble automatically saves any changes made in that element to the database, so you don't need to set up any actions to make it happen.

Auto-binding is tied to a field, so the data format of the input element and the field must match. For example, a field that holds a date must be connected to an input element that expects a date from the user.

Auto-binding only works if the parent of the input element has a data type loaded into it, and it can't create new things, only write to things that already exist.

In the example above, we've set up a text input element that automatically saves its input to the Name field on the user. The user is loaded into the parent, which is either a container element or the page itself.

The data saves whenever the element loses focus, meaning the user has clicked or tabbed away from the input field. Bubble briefly shows a loading bar to let the user know the data is being saved.

Auto-binding on an input runs immediately, rather than waiting for the "next step" when you're using the step-by-step feature in the debugger.

Showing an alert on success

When auto-binding is active, you can show an alert to let the user know it worked. First, place an alert element on the page. Then check Show an alert on success to select which alert element to use and what message to show.

In the screenshot above, we've created an alert element and checked Position the alert at the top, so it displays as a full-width bar at the top of the page.

On the input with auto-binding enabled, we've picked the alert element we just created, along with a custom message that matches the field being changed.

Comparing workflows and auto-binding

There are a few key differences to weigh when choosing between workflows and auto-binding.

UX

The first is how it affects the user experience. In some forms, it makes sense to let users review their information before anything saves, until they click a button. In others, it's more efficient to save information as soon as a field is edited. It's up to you as the developer to decide what fits best in each case.

Security

Bubble handles security on actions and auto-binding a bit differently. With actions, you control editing rights with conditionals on the workflow. With auto-binding, you control editing rights with privacy rules.

Workflows

Workflows aren't affected by privacy rules and need their own conditional expressions to control who can do what. For example, in the action below, we've set up an expression that only allows a user to edit a profile if it's their own:

Auto-binding

Auto-binding relies on a dedicated privacy rule that dictates under what circumstances changes to the field will save. The field stays editable, but when it loses focus, it generates an error message if privacy rules don't allow the user to save changes through auto-binding.

Performance

Workflows and auto-binding also differ slightly in how they perform:

  • Workflows send all the changes that need to be made in one batch to the server. This means fewer slowdowns, but the ones you do have may take a bit longer, depending on how much data is transferred.

  • Auto-binding sends updated information to the server immediately when a field is edited. This means more frequent, but typically shorter, data transfers.

There's no single right answer here. The difference is often small enough to be negligible, but it's still worth weighing against the overall user experience to decide which method fits best.

The database editor

Bubble also lets you edit data directly in the built-in database editor. This works for both the Development database and the Live database.

You'll find the database editor in the Data tab, under App data. Select the data type you want to edit, search for a specific thing, and click the edit icon to make changes.

Editing directly in the database is useful for quick updates, but as a long-term solution, we recommend setting up your own forms to edit data instead.

Video lessons

FAQ

FAQ: Creating, saving, and deleting data

What's the difference between a workflow and auto-binding?

A workflow saves changes when a specific event happens, like a button click, so the user controls when data is saved. Auto-binding saves changes automatically, as soon as the user edits a field and moves away from it. Which one to use depends on the experience you want: a workflow if you'd rather users review their changes first, auto-binding if you want changes saved immediately.

Can auto-binding create a new thing?

No. Auto-binding only works on things that already exist. The parent container's thing needs to be loaded before auto-binding can save anything to it.

Are workflows affected by privacy rules?

Not for editing rights. Privacy rules don't control who's allowed to make a change through a workflow, you need your own conditional expressions in the workflow or action for that.

Privacy rules can still affect a workflow in other ways, though. If an action involves searching for something, like a Do a search for, that search is still governed by whatever privacy rules control search visibility.

Is auto-binding affected by privacy rules?

Yes. Auto-binding relies on a dedicated privacy rule for each field. If the rule doesn't allow the current user to save changes, the field stays editable, but the user gets an error message when the field loses focus and the data is not saved.

Can I run additional actions after auto-binding saves?

Yes. Set up a workflow using the An input's value has changed event, and add your actions there. Keep in mind the auto-bind save may not have finished by the time those actions run, so if an action depends on the data already being saved, it's safer to handle the save in a workflow instead.

Can I show a confirmation message when auto-binding saves successfully?

Yes. Place an alert element on the page, then check Show an alert on success on the input with auto-binding enabled. You can pick which alert element to use and customize the message.

Note that auto-binding and alert elements are only available in web apps.

Why does my input's data format need to match the field?

Auto-binding connects an input element directly to a field, so whatever the input collects has to match what the field expects. For example, a date field needs an input that provides a date, not plain text.

How do I edit user email or password?

You can't use Make changes to a thing for these. Because of the sensitive nature of user credentials, they need their own dedicated actions to keep them secure. You need to use the Update the user's credentials action

Can I edit data without setting up a form?

Yes. The database editor lets you edit things directly, without workflows or forms. You'll find it in the Data tab, under App data. It's useful for quick fixes, but for anything ongoing, we recommend building your own forms instead.

Is there a performance difference between workflows and auto-binding?

A small one. Workflows send all changes in a single batch, which usually means fewer but slightly longer transfers. Auto-binding sends each change as soon as it happens, which means more frequent but typically shorter transfers. In practice, the difference is often negligible, so it's usually not the deciding factor.

Other ways to learn

Did this answer your question?