---
title: Use databases in a flow
project: TAS
version: 10.0
section: guides
language: en
translation: missing
license: Total.js Enterprise
url: https://totaljs.es/docs/de/tas/10-0/guides/database-components/
updated: 2026-11-20T06:40:13.748Z
---

# Use databases in a flow

> Read and write the rows of a database from a flow with its database component.

Every database of your app is also a component in the flow designer. You find them in the **Databases** group of the component list, with the name and icon of the database. When you create, change or remove a database, TAS updates these components in all flows.

## What the component does

A database component has one input and two outputs:

- **Input**: a message arrives and the component runs its code.
- **Output**: the result of the code.
- **Error**: the error, when the code fails.

The component shows the table it works with, for example `db.db539792`.

## Write the code

Double-click the component in the designer to open its settings. The settings contain one piece of JavaScript. Select **Read me** to see the columns of the database.

![The settings of the Customers component](/files/JaswvZ2P860f.webp)

The code returns the result of one of these methods:

- `READ()` returns one row.
- `FIND()` returns a list of rows.
- `LIST()` returns a list of rows split into pages.
- `INSERT(data)` inserts a row and returns its `id`.
- `UPDATE(data)` updates rows.
- `REMOVE()` removes rows.

Use each method on its own line. You can add conditions to it, for example `.where('active', true)`. `INSERT()` and `UPDATE()` keep only the values of known columns and ignore the rest. `INSERT()` creates the `id` when the data has none.

`data` is the data of the incoming message. With a [data view](../data-views/), `data.query` holds the query string of the request.

Some examples:

```js
// all rows
return FIND();
```

```js
// one row by the "id" in the query string
return READ().where('id', data.query.id);
```

```js
// active customers only
return FIND().where('active', true);
```

After you change the code, select **APPLY** in the settings and then **APPLY** in the designer.

See [Return database rows as JSON](../../recipes/rows-as-json/) for a complete example.
