Skip to content

Managed data stores

A managed data store is a table Crios creates for you in the project's own database, so a workflow can keep rows between runs without you designing a schema. Creating one gives you two things: the table, and a Postgres connection named after the store that the Database read and Database write nodes can bind straight away.

A store is a convenience on top of the project database. If you want tables of your own design, bind the project database's connection instead and create them with the Database write node's Setup statement (see Writing rows).

How a store gets created

Stores are created, listed and deleted through the workflows endpoints of the REST API; there is no data-store screen in the app.

Call Does
POST /api/v1/workflows/data-stores Creates a store from a project_id and a name. Needs Editor access to the project
GET /api/v1/workflows/data-stores?project_id=… Lists the project's stores. Viewers may call it
DELETE /api/v1/workflows/data-stores/{id}?project_id=… Deletes a store. Needs Editor access. Refused with 409 while the live version of a workflow binds the store's connection

A created store comes back with its id, name, table_name and the credential_id of its connection. The table goes into the project's database, which is created on the spot if the project does not have one yet. When a Postgres server of your own is the project's app database, the table goes there instead.

A store stays in the database it was created in. On deployments that keep a development copy of the project's database, that is the build's database before the project's first publish, and the published app's after it. The first publish copies the build's database into the app's, so a store created before it leaves a copy of its table there — but the store's connection keeps reaching the build's database, and that is where workflows using the store read and write. Where the build and the published app share one database, there is only that one. When the build's database has gone to sleep after a quiet hour, a workflow step that uses the store wakes it first. To keep a store in the published app's database, create it after the first publish.

When you generate a workflow, the generator is told which stores the project already has and uses one when it fits. It does not create stores.

Not available on every deployment

Managed data stores need project databases. On a deployment without them, the API answers managed data stores are not configured. Bind a Postgres or MySQL server of your own instead; see the end of this page.

What a store looks like

Every store has the same four columns:

Column Type What it holds
id auto-incrementing integer The row's primary key, assigned for you
payload JSON Your data — required on every row
occurred_at timestamp with time zone Optional: when the thing you are recording happened, if that differs from when the row was written
created_at timestamp with time zone When the row was inserted — defaults to now

The shape is fixed. You model your own structure inside payload and reach into it with Postgres's JSON operators, rather than adding columns.

Naming

You choose the name, up to 200 characters. Crios derives the table name from it: wd_, the first eight characters of the project's id, then the name lowercased with every run of other characters turned into one underscore, cut short so it stays a valid identifier. You never type the table name when you create the store, but you use it in SQL.

Names are unique within a project, and they share that space with Postgres connections, because the store's connection carries the store's name. A clash is refused — a data store or postgres credential named "…" already exists in this project — and you retry with a different name.

Writing rows

Rows go in through the Database write node, which runs one SQL statement per input item. Set:

  • Engine — postgres.
  • The postgres slot in the node's Connections section — pick the store's connection, which carries the store's name.
  • Statement — the SQL, with $1, $2, … where values belong.
  • Params — those values in order. Each entry accepts an expression.
  • Setup — optional. One statement, such as CREATE TABLE IF NOT EXISTS …, run without params before the main statement, for every input item and again on every retry. Keep it idempotent. A store's table already exists, so a store does not need one; it is how a workflow creates a table of its own in the project database.

Recording each incoming item's JSON, with the item's own timestamp in occurred_at:

INSERT INTO wd_3f9a1c02_order_intake (payload, occurred_at)
VALUES ($1::jsonb, $2::timestamptz)
{{ json(item.json) }}
{{ item.json.created_at }}

Values go in Params, never into the statement: a statement or setup containing {{ }} is rejected when you activate the workflow and again if a run reaches it. Because dynamic values only ever arrive as bound parameters, an expression cannot rewrite the SQL. An expression resolving to something other than text is bound in its rendered text form, and one resolving to a path that does not exist is bound as an empty string.

The input items pass through unchanged.

A statement the database refuses on its merits fails the step at once, without retrying, because it would fail the same way every time: a syntax error, a missing table or column, a broken constraint such as a duplicate unique key, a value the column cannot hold, or missing privileges. So does a login the server refuses: fix the connection. A lost connection, a timeout or a deadlock is retried.

On Postgres, an INSERT … ON CONFLICT … DO UPDATE that reads one of its inserted columns without naming whose value it means — SET payload = payload || $2::jsonb, say — is a warning in the Problems panel when you save and an error when you publish, because Postgres refuses it as ambiguous on every run. Write <table>.payload for the stored value or EXCLUDED.payload for the new one.

Reading rows

The Database read node runs a read-only query against the same connection and outputs one item per row. The statement must start with SELECT or WITH, be a single query, and carry no write or DDL keywords — anything else is rejected at activation and again at run time. Those keywords count as whole words anywhere outside quotes and comments, so a column named comment, set, show or copy is refused too; on Postgres, write it in double quotes ("comment"). One semicolon at the very end is allowed; a semicolon anywhere else outside quotes and comments counts as a statement separator and is refused. Values are bound from Params exactly as they are on the write node.

SELECT id, payload, created_at FROM wd_3f9a1c02_order_intake
WHERE payload->>'status' = $1
ORDER BY created_at DESC
LIMIT 50

The node runs once per step rather than once per item, so the expressions in Params are evaluated once: item is the first input item, and items holds them all. The input items are not passed on: the rows replace them. Each emitted item's json is one row keyed by column name. JSON columns come back as real objects — payload is ready to read as item.json.payload.… — and timestamps arrive as RFC 3339 strings. Postgres arrays come back as lists: a NULL element is null, and an empty array is [].

To look up rows for every input item, query once for all of their keys: bind them as one JSON array and unpack it in SQL.

SELECT * FROM customers
WHERE email IN (SELECT jsonb_array_elements_text($1::jsonb))
{{ json(unique(map(items, i, i.json.email))) }}

Reading the whole table and matching afterwards is not a substitute: the read stops at Limit without saying so.

Limit caps how many rows become items: default 100, hard cap 1000. It is a safety valve, not pagination — it stops reading once that many rows have arrived, in whatever order the query produced them. To page deterministically, write your own LIMIT and OFFSET and sort on something stable, as above.

The Data Table node

The Data Table node is the no-SQL way to keep rows in a database. It needs no store and no API call: bind a Postgres connection — usually the project database — to its postgres slot and name a table. Its tables are simpler than a store's, with two columns: id, assigned for you, and a JSON payload. They live in the bound database under a wf_dt_ prefix, so a table you call orders is wf_dt_orders there.

  • Resource row offers insert, get, update (merges the new top-level fields into the stored payload), upsert (inserts, or replaces the row with that id) and delete.
  • Resource table offers create, list, clear and drop.
  • Table is the name without the prefix: letters, digits and underscores, not starting with a digit, at most 57 characters, and not an expression.
  • Data is the row as a JSON object whose values may use expressions. The key id is reserved: a step that sets it fails, and set literally it is a warning when you save and an error when you publish.

A row operation never creates its table. Put a step with Resource table and Operation create before the first write; it is idempotent, so it can run on every execution. A row operation on a table that does not exist fails at once, without retrying, with a message that names the table and the bound connection and lists the data tables that database does hold: a misspelled name, or a table created through another connection, shows up there.

Every operation runs once per input item. A row operation outputs the affected row as its id plus the payload's fields; get and delete output nothing when no row matches, and update fails, naming the id. A table operation outputs each table it touched as name and tableName, and list outputs one item per data table in the database. Either way the output replaces the input items. Values reach the database only as a bound parameter.

Deleting a store

Deleting a store drops its table in the database the store was created in, removes the store, and deletes its connection along with the stored secret. A copy the first publish made in the published app's database is the app's and is not dropped.

Like deleting a connection on the Connectors page, deleting a store is refused while the live version of a workflow binds its connection: the answer is 409 and names those workflows — pause or rebind them first. Drafts do not count.

Deletion is permanent

Dropping the table destroys its rows, and there is no undo — export anything you want to keep first.

What a store is not

  • Not a database of your own design — a store is one table with the four columns above. Structure beyond that lives inside payload, or in tables you create in the project database yourself.
  • Not per-table access — the store's connection reaches the whole project database, including the app's own tables, not only the store's table. Treat it as project-level database access: anyone who can edit the project's workflows can use it. It reaches nothing outside the project's database.
  • Not a surface in the app — you meet a store through the API and through the connection it leaves in a node's Connections section.

Bring your own database instead

If you already run Postgres or MySQL, you do not need a managed store: add a connection for it on the project's Connectors page and bind it to the same slot — postgres, or mysql with ? placeholders instead of $1. Everything else on this page applies unchanged, including the params-only binding rule, the read-only guard, and the row limit. Only the table shape becomes yours to design. To make your own server the database of the app itself, see Project databases. For the nodes themselves, see the Node reference.