Skip to main content
The Database step works with a Database store of the agent the workflow belongs to. Save a new lead, look up an order, update a status, or run a query, without leaving the workflow.

When to use

  • Save a record: a lead from a form, an order from a webhook
  • Look something up before deciding what to do next
  • Update a row when a status changes
  • Go through many rows with a Loop
  • Total or join with a SQL query

Operations

Pick the Database store and the Operation. The form shows only the settings that operation uses. Every value field takes {{…}} from earlier steps, including {{agent.…}}.

Filter and sort

Find and Update take a filter as a list of conditions on columns. Use eq, ne, gt, gte, lt, lte, in, like and is_null:
An Update by filter needs a filter. It never changes every row by accident. Find returns up to the limit you set. When truncated is true, more rows match. Pass nextCursor back in a second Find step to read the next page.

SQL

Choose SQL to write the statement yourself, and choose Read or Write mode. Put values in Parameters, not in the text:
with the parameters {{start_1.email}} and 100. The statement itself is never filled in from earlier steps. This keeps a customer’s text from changing what the query does.

Example: save a lead and tell the team

1

Take the lead

A Webhook starts the workflow with a name and an email.
2

Check for a duplicate

A Database step, Find, table leads, filter {"email": "{{start_1.email}}"}.
3

Save it if new

A Condition on {{database_1.rows.length}}. On the new branch, a Database step, Insert, table leads, with the name and email.

When things go wrong

Used as a tool

When an LLM step uses this step as a tool, pin one operation in the step first. The AI then picks the values, never the operation.

Settings

string
required
The Database store, by its key.
string
required
insert, get, find, update, delete or sql.
string
The table, for every operation except SQL.
number
The row’s id, for get, update and delete.
object
Conditions for find and update.
string
The statement, for SQL. Never filled in from earlier steps.
array
The values for the statement’s placeholders.
string
default:"read"
read or write, for SQL. Never filled in from earlier steps.

Next steps

Database

Tables, the designer and the SQL console.

Loop

Go through the rows a Find returns.