Data

Table

Reads and writes the rows of a table in My Data: find a customer by email, list today's orders, add a booking, mark a task as done, count the unread messages. It is the node to use for every table on the new table engine.

Which tables? Tables on the new engine use this node. An older table shows Move to the new engine in My Data: press it to use this node, or keep using Query Data and Write Data on it.

Settings

Setting What it does
Table The table to work on
Method What to do: find, count, add, change or delete rows (see below)
Arguments The details: which rows, which values. Written as JSON, the format of fields in curly braces, with your {{variables}} as values
Output Variable The name to read the result by, such as customer

Inside the arguments, columns are named exactly as in the table. Every row also has _id (its unique id), created_at and updated_at.

Methods

Reading:

Method What it does Gives back
findFirst Finds the first row that matches That row, or nothing
findUnique Finds one row by its _id or by a unique column, such as email That row, or nothing
findMany Finds every row that matches A list of rows
count Counts the rows that match A number
groupBy Totals rows per value, such as orders per status A list of groups
aggregate Totals over every matching row, such as the sum of all orders One set of totals

Writing:

Method What it does Gives back
create Adds a row The new row, with its _id
createMany Adds many rows at once, from a list { count }
update Changes one row, found by _id or a unique column The changed row
updateMany Changes every row that matches { count }
upsert Changes a row if it exists, adds it if it doesn't The row
delete Deletes one row The deleted row
deleteMany Deletes every row that matches { count }

createManyAndReturn and updateManyAndReturn work like createMany and updateMany, but give back the rows themselves.

Examples

Find a customer by email (findUnique, output customer):

{ "where": { "email": "{{email}}" } }

Then {{customer.name}}, {{customer._id}}. When there is no such customer, {{customer}} is empty: check it with a Condition, {{customer}} == "".

The latest 20 open orders of the signed-in user (findMany, output orders):

{
  "where": { "customerId": "{{jwt.sub}}", "status": "open" },
  "orderBy": { "created_at": "desc" },
  "take": 20
}

Add a booking (create, output booking):

{ "data": { "name": "{{name}}", "email": "{{email}}", "date": "{{date}}", "status": "new" } }

Mark a task done, only if it belongs to the caller (update):

{
  "where": { "_id": "{{task_id}}", "ownerId": "{{jwt.sub}}" },
  "data": { "done": true }
}

Orders and revenue per status (groupBy, output totals):

{ "by": ["status"], "_count": { "_all": true }, "_sum": { "total": true } }

Each group looks like { "status": "paid", "_count": { "_all": 3 }, "_sum": { "total": 120 } }.

Choosing rows: where

where says which rows to work on. The simplest form names a column and a value: { "status": "open" }. Several columns must all match.

For anything other than "equals", give the column an operator:

Operator Matches Example
equals, not equal, not equal { "status": { "not": "cancelled" } }
in, notIn one of a list, none of a list { "status": { "in": ["new", "paid"] } }
lt, lte, gt, gte less, less or equal, greater, greater or equal { "total": { "gte": 100 } }
contains, startsWith, endsWith text containing, starting or ending with { "name": { "contains": "{{q}}", "mode": "insensitive" } }

Combine with OR, AND and NOT: { "OR": [ { "status": "new" }, { "priority": "high" } ] }.

  • Text matching notices capitals, unless you add "mode": "insensitive".
  • A multiselect column is a list: { "tags": { "has": "vip" } }, or hasSome, hasEvery, isEmpty.
  • A JSON column is searched by a path inside it: { "meta": { "path": ["source"], "equals": "ads" } }.

More you can ask for

Argument What it does Example
orderBy Sorts the rows { "created_at": "desc" }
take, skip How many rows, and how many to skip first (for pages of results) "take": 20, "skip": 40
select Gives back only these columns { "name": true, "email": true }
omit Gives back every column except these { "password_hash": true }
include Adds the linked row from another table { "customer": true }
distinct Keeps one row per value ["city"]

include, and counting linked rows with _count, need the two tables to be linked: a column that holds the other table's _id, declared as a link in My Data.

findMany has no limit of its own, so always give it a take. A read of more than 10,000 rows fails.

Filters the caller may leave out

For a list with optional filters, such as a status or a date range the user may or may not choose, list those columns under Optional. A filter whose variable came in empty is then simply left out, instead of searching for empty values.

Sorting the caller chooses

To sort by a column the request names, write "orderBy": { "{{sort}}": "{{dir}}" } and list the columns allowed under Sortable, such as name and created_at. A column that isn't listed is refused.

Changing many rows, each differently

To save a reordered list, where every row gets its own new position, set Each to the list ({{ranks}}) and As to a name for each item (card). The write then runs once per item, all together: if one fails, none is kept. Up to 1,000 items.

{ "where": { "_id": "{{card._id}}" }, "data": { "rank": "{{card.rank}}" } }

Don't use a For Loop of single writes for this: it is much slower and can stop halfway.

When something goes wrong

A failed call stops the node with an error that starts with a code:

Code Means
P2025 update or delete found no row
P2002 The value is already taken in a unique column, such as an email that is already registered

To answer 404 or 409 instead of failing, put the node inside a Try / Catch and read {{tryCatch.lastError}} on its error path. Or use updateMany or deleteMany with the same where, and check {{result.count}}.

Keeping data safe

  • Values are only ever values. A {{variable}} can't change your filter: whatever a caller sends is compared as plain text, so they can't widen a search to see other rows.
  • Tie rows to the caller. In an endpoint behind a login, put {{jwt.sub}} in the where of every read or change of a user's own rows.
  • Name every column you write. "data": { "name": "{{name}}" }, never the whole request at once, so callers can't fill in columns you didn't intend.
  • Never send password hashes or secrets back. Password and secret columns come back masked as ********. Leave them out with omit as well.
  • Scoped tables. A table scoped by organization keeps each caller to their own organization's rows by itself. Don't filter on its scope column, and don't set it when writing.

Good to know

  • Dates and times come back in your workspace's time zone, such as 2026-01-02T12:00:00.000+02:00. Currency values come back as text.
  • Execution Logs show for every call how long it took and how many rows it read and changed. A slow search names the column to index: turn Indexed on for it in My Data.

Related

We update these pages often. Spotted something out of date? Tell us

AI AssistantPowered by Ubex
Beta
Ask me anything about Ubex workflows, nodes, or the API.