Skip to main content

Databases and tables

In one sentenceA table is Lumen's own spreadsheet: typed columns, an optional key that stops duplicates, and rows that flows add, find and update and that people read in the console.

Tables are for the records your automations produce: one row per invoice, per lead, per delivery. They are not Google Sheets, and they are not a copy of a file. If you need to edit an Excel or CSV file that already exists, see Spreadsheets instead.

Databases and tables​

A database groups tables, the way a folder groups files. It has a name, an icon and a color. A table belongs to exactly one database and appears in it as a tab. In the API and in YAML a table is a Sheet and a database is a SheetBase.

A table's definition (its title, columns and key) is a workspace resource, like a flow. Its rows are stored in Postgres, not in the Kubernetes cluster, so a table that gets thousands of rows a day never slows the rest of Lumen down. Deleting a table deletes its rows. A table made again under the same name starts empty.

LimitDefault
Rows per table100,000. A full table refuses further adds.
Size of one row64 KiB of values
Columns per table100
Key columns8
Options per choice or select column100

Self-hosted installs can change the row limits in the Helm chart.

Columns and types​

Every write is checked against the column's type, so a total column never holds a word. A refused value fails the step with a sentence that names the column, for example total: "lots" is not an amount.

TypeHoldsIn the console
textFree text, up to 16 KiBShort text
numberA decimal number. 12.5 and 12.50 are the same value.Number
moneyAn amount and a three-letter currency. A value without a currency takes the column's currency, ILS when unset.Currency
dateA calendar date, YYYY-MM-DDDate
booleanYes or noCheckbox
choiceOne of a fixed list(kept for existing tables)
selectOne option from a list, or with multiple: true several. Each option has a color.Select, Multiple select
fileA reference to a file Lumen keeps, never the bytes, and only your workspace's own files. Click the cell to download.File
userA member of the workspaceUser
formulaWorked out from the other columns of the row when it is written. Read only.Formula

A column has a name, which is its stable id (lowercase letters, digits, _ or -), and a title, which is what people see. The title can change; the name cannot, because flows refer to it. A column marked required makes a row without a value invalid.

Two rules to know before you design a table:

  • Removing a column hides it. Its values stay in the rows and come back if you add a column with the same name and type.
  • A column's type is fixed. The only changes are choice to text or select, and a single select to text. Otherwise add a new column, move the values, and remove the old one.

Related records (link, lookup, rollup) are shown in the console as Coming soon and are refused for now.

The key​

A table can name up to eight columns as its key. Together they identify a row: no two rows have the same key, and two values count as the same when they are the same value (12.5 and 12.50). Key columns are always required, and a formula, a multiple select or a file cannot be one.

A key does two things. It stops duplicates, and it lets a flow add or update by it: with mode: upsert, Add a row to a table sets the values on the row that has the same key, or adds the row if none does. An invoice that arrives twice updates its row instead of adding a second one.

Choose the key before you create the table

The key is set when the table is made and cannot change afterwards, because rows are indexed by it. A table with no key cannot be upserted into.

Define a database and a table​

A table names its database in baseRef and its place among the tabs in position. The database must exist.

finance-database.yaml
apiVersion: lumen.ai/v1alpha1
kind: SheetBase
metadata:
name: finance
namespace: tenant-acme
spec:
displayName: Finance
icon: bank
color: blue
---
apiVersion: lumen.ai/v1alpha1
kind: Sheet
metadata:
name: invoices
namespace: tenant-acme
spec:
displayName: Invoices
baseRef: finance
position: 0
columns:
- {name: supplier, title: Supplier, type: text, required: true}
- {name: invoice_no, title: Invoice number, type: text, required: true}
- {name: total, title: Total, type: money, currency: ILS}
- {name: vat, title: VAT, type: formula, formula: "ROUND({total} * 0.17, 2)"}
- {name: due, title: Due date, type: date}
- {name: status, title: Status, type: choice, choices: [open, paid]}
- {name: scan, title: Scan, type: file}
key: [invoice_no]

Apply it with lumen apply -f finance-database.yaml. A new table must name a database.

A database that still has tables cannot be deleted: move its tables to another database or delete them first. A table that flows still write to cannot be deleted either, and the console names the flows to change first.

Read and edit a table in the console​

Databases in the sidebar lists your databases. Open one to see its tables as tabs.

The Databases page with three database cards: Finance with 3 tables and 24 rows, Operations with 5 tables and 26 rows, and Marketing with 2 tables and 8 rows. Each card shows an icon, a description and when it was last updated. A dashed New database card follows.The Databases page with three database cards: Finance with 3 tables and 24 rows, Operations with 5 tables and 26 rows, and Marketing with 2 tables and 8 rows. Each card shows an icon, a description and when it was last updated. A dashed New database card follows.
Databases lists each database with its table and row counts.
The Finance database open on its Invoices table. Tabs for Invoices, Suppliers and Monthly expenses sit above a Rows and Forms switch. The toolbar has a search box and icons for filter, sort, fields, views and automation, and on the right add row, delete and export. The grid shows columns Invoice no., Supplier, Issued, Total, Status, VAT included and Invoice file with three invoice rows.The Finance database open on its Invoices table. Tabs for Invoices, Suppliers and Monthly expenses sit above a Rows and Forms switch. The toolbar has a search box and icons for filter, sort, fields, views and automation, and on the right add row, delete and export. The grid shows columns Invoice no., Supplier, Issued, Total, Status, VAT included and Invoice file with three invoice rows.
A table: tabs for the tables, a toolbar, and typed cells. Money is formatted in its own currency, a select shows as a colored dot.

What the toolbar offers:

ControlWhat it does
Search rowsFinds text in the visible columns of the loaded rows.
Filter, SortFilter by a column and sort by one column. Both run on the server, so they cover every row.
FieldsHide or show columns.
ViewsA view is a saved filter, sort, set of hidden columns and column widths. It is shared with the workspace or personal to you. Admins save shared views; a member's changes are saved as a personal view.
AutomationWhat writes to this table: the flows and agents, and a Source column that says per row whether a run, an agent or a person made it.
Add row, Delete rowsAdmins only. Tick rows to delete several at once. Deleting is permanent.
Export CSVDownloads the whole table, not only the loaded rows, as a CSV file that opens in Excel. It applies the current filter, sort and visible columns.

To edit a cell, click it, type, and press Enter to save and move down. Esc cancels. A refused value keeps the cell open and shows the reason. Pasting a table from Excel or Google Sheets fills several cells at once (over 50 rows it asks first), and Ctrl+Z undoes the changes of your visit.

Import: the console has no file import. Paste a table from a spreadsheet into the grid, or let a flow add the rows.

Work with tables in a flow​

Three steps work on a table, and a fourth turns rows into a file. In each, the table is named in sheet (and optionally base, which makes the step fail if the table is not in that database).

StepConsole titleWhat it doesCredits
add-rowAdd a row to a tableAdds the document's fields as a row.1
find-rowLook up a row in a tableFinds a row and brings its columns into the steps after it.1
update-rowUpdate a row in a tableFinds a row and changes the columns you choose.1
make-csvMake a CSV fileTurns a list of rows into a CSV file.0.5

Add a row​

mapping says what goes in each column. A value is "{field}" alone, which carries the field's own value, so a total stays money and a date stays a date, or text with placeholders, which is read as the column's type. A column you leave out takes the field with the same name. To fill a file column, map it to "{file}".

mode: insert (the default) always adds a row, and a step that runs again after a lost worker still adds once. mode: upsert updates the row with the same key or adds one, and needs a table with a key. The step adds the fields rowId and rowCreated.

Find a row​

where is a list of up to eight tests that must all pass. Each has a column, an op (eq by default, contains, gt, gte, lt, lte) and a value that may hold placeholders. The first match's columns become fields for the steps after it, with prefix in front of the names if you want one. The step also adds found, count and rowId.

all: true brings every match as the list field rows, up to limit (50 when unset, 10,000 at most). When more rows matched than the limit allowed, truncated is true, so an export is never cut short silently. If a test's value is missing, the step finds nothing and says what it lacked; it never drops the test.

Update a row​

where finds the oldest matching row and set is a mapping of the columns to change. A value that turns out empty leaves its column as it is. ifMissing is fail (the default) or skip. The step adds rowId and updated.

Make a CSV file​

from names the list field (rows, find-row's, when unset). columns picks and renames columns in order, each with a name and an optional title; unset, every key the rows have is written. filename may hold placeholders (export.csv when unset). bom (on by default) starts the file with a UTF-8 byte order mark so Excel reads Hebrew. A cell that starts with =, +, - or @ is prefixed so a spreadsheet does not run it as a formula. A file holds at most 10,000 rows. Its output is a file, so you can save it, attach it to an email or rename it like any other.

An example flow​

This flow reads an invoice, finds the details with an AI step, and upserts them by invoice number. It writes to the table defined above.

data-invoice-ledger.yaml
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: data-invoice-ledger
namespace: tenant-acme
spec:
displayName: Invoice ledger
triggers:
- id: manual
ref: {name: manual-run}
next: [text]
nodes:
- id: text
stepRef: {name: read-text}
next: [details]
- id: details
stepRef: {name: chat-agent}
config:
instructions: Find these details in the invoice.
fields: [{name: supplier}, {name: invoice_no}, {name: total, type: money}, {name: due, type: date}]
files: {mode: ifNoText}
next: [row]
- id: row
stepRef: {name: add-row}
config:
base: finance
sheet: invoices
mode: upsert
mapping: {supplier: "{details.supplier}", invoice_no: "{details.invoice_no}", total: "{details.total}", due: "{details.due}", status: open, scan: "{file}"}

A second flow reads the open invoices back out as a CSV file and saves it to a folder in Files:

data-open-invoices-export.yaml
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: data-open-invoices-export
namespace: tenant-acme
spec:
displayName: Open invoices as CSV
triggers:
- id: manual
ref: {name: manual-run}
next: [find]
nodes:
- id: find
stepRef: {name: find-row}
config:
sheet: invoices
where: [{column: status, op: eq, value: open}]
all: true
limit: 1000
next: [csv]
- id: csv
stepRef: {name: make-csv}
config:
from: rows
columns:
- {name: supplier, title: Supplier}
- {name: invoice_no, title: Invoice number}
- {name: total, title: Total}
filename: "open-invoices.csv"
next: [keep]
- id: keep
stepRef: {name: save-file}
config: {destination: lumen, folder: "Exports/{flow}"}

In the console, the same steps are in the step picker as Add a row to a table, Look up a row in a table, Update a row in a table and Make a CSV file. The editor proposes columns from the fields a step would receive.

Use tables from an agent​

An AI agent step can call add-row, find-row and update-row as tools. List them in the agent's tools, name the table in its instructions, and the model fills each tool's settings (sheet, where, mapping) as its input. Each successful call costs the step's credits on top of the agent's own. A call the table refuses is shown to the model and not charged.

data-supplier-assistant.yaml
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: data-supplier-assistant
namespace: tenant-acme
spec:
displayName: Supplier assistant
triggers:
- id: manual
ref: {name: manual-run}
next: [assistant]
nodes:
- id: assistant
stepRef: {name: chat-agent}
config:
instructions: >-
Answer questions about our invoices. Look them up in the table
invoices. Mark an invoice paid when the person says it was paid.
tools: [find-row, update-row]

Next steps​