Skip to content

Column types

A table declares columns. Each column has a type. The type decides three things at once: how the value is stored, which control a form renders for it, and which checks run before a write is accepted.

You declare a column with a name, a type, and a label:

table members "Members" {
display: name
name text required "Name"
email email "Email address"
joined_on date required "Joined on"
fee_cents money "Annual fee"
}

The label is the last item on the line. Every declaration in the language follows this rule.

A single line of text, up to 255 characters. The form renders a one-line input. A max: below 255 sets a lower limit. A max: above 255 does not raise the limit.

Text of more than one line. Write the type as two words.

title text required "Title"
notes long text "Notes" { rows: 8 }

A long text is stored as text, like text. The form renders a textarea of 5 lines, and rows: sets a different height. There is no length limit unless the column has a max:. A long text column is truncated in a report, because a table cell is too small for a paragraph.

Formatted text that an author writes in Markdown. The engine parses it with raw HTML disabled and sanitizes the result a second time. It also keeps a plain-text copy for search.

A markdown column is not a long text column with formatting. It is a contract about what the engine accepts and what it renders.

The form renders a textarea of 12 lines, and rows: sets a different height.

body markdown required "Body" { max_kb: 64 }

max_kb: is the largest text that a save accepts, in kilobytes of 1024 bytes. It takes a whole number from 1 to 4096. The default is 256. The engine measures the text in bytes after it changes line endings to \n, and before it parses the Markdown. A longer text refuses the save, and the field shows “The text is too long (at most 64 KB).”

The compiler refuses max_kb: on a column that is not markdown, and a value outside 1 to 4096.

A form shows a markdown field as a visual editor. You do not declare anything to get it. The text looks as it will look on the page, and a toolbar above it applies formatting:

Button Keyboard (Ctrl on Windows and Linux, Cmd on a Mac) Markdown it writes
Heading, Subheading Ctrl+Alt+1, Ctrl+Alt+2 # , ##
Bold, Italic, Code Ctrl+B, Ctrl+I, Ctrl+E **bold**, *italic*, `code`
Link Ctrl+K [text](address)
Bulleted list, Numbered list Ctrl+Shift+8, Ctrl+Shift+7 - , 1.
Quote Ctrl+Shift+9 >
Code block, Divider — a fenced block, ---
Undo, Redo Ctrl+Z, Ctrl+Y (Cmd+Shift+Z on a Mac) —

Markdown typed into the editor also turns into formatting: ## at the start of a line makes a subheading, - a list, and **word** a bold word. Plain text that is pasted is read as Markdown. Pasted formatted text keeps only the formatting in the table above.

Ctrl+] and Ctrl+[ indent and outdent a list item. The Tab key is not used by the editor, so it always moves to the next field.

The Markdown button on the right of the toolbar shows the text as Markdown source. Press it again to go back. The form saves the Markdown in both views.

Some things to know:

  • The editor stores Markdown. Nothing else is saved, and the rules in this section apply to text from the editor as they do to typed Markdown.
  • An untouched field is saved exactly as it was stored. The editor writes the field only after you change it. Saving a form in which you changed only the title does not rewrite the text.
  • A table is edited as Markdown source. It shows under the label “Table – edited as Markdown” inside the visual editor.
  • Some texts open in the Markdown view. A text with a table inside a list or a quote cannot be shown by the visual editor without changing it. It opens as Markdown, with a note that says why.
  • Formatting next to punctuation can move. Markdown cannot mark some positions as bold or italic, for example italic “(note)” directly after a letter. The editor then moves the formatting inward, to “(” + note + “)”, as you apply it. What you see is what is saved.
  • Without JavaScript the field is a text box that holds the Markdown source, and the form saves it in the same way.

A Markdown text can show a picture that is stored in an img column of the same application. Write a Markdown image whose address is the picture’s address:

![The site plan](/matterdata/blob/media/file/2/<digest>)

The four parts after blob/ are the table, the img column, the row id, and the picture’s digest. Add .thumb to the digest for the 320-pixel thumbnail. Copy the address from a page that shows the picture.

In an application under a mount, a page shows the address with the mount in front, for example /club/matterdata/blob/media/file/2/<digest>. You can write either form. The engine stores the text as you wrote it and shows the picture under the application’s mount. The visual editor in a form shows the picture from the same address. An address under the mount of a different application is refused.

When a form or a sheet saves the text, the engine checks each image that the text did not already contain. The person who saves must be able to open the picture: a page of the application must show them that row and that column. If the check fails, the save is refused and the markdown field shows this message, with the address that was written:

The text shows an image that is not available: /matterdata/blob/media/file/99/…. Use the address of a picture in this application, or remove the image.

The message is the same for a row that does not exist, a row that does not hold that picture, and a row the person may not see. The save does not tell the person which rows exist.

An address outside the application, such as https://…, is also refused. The engine never shows an image from another site.

The check applies to the person who saves, not to every reader. A reader who may not see the picture’s row sees the word “Image” and the alt text instead of the picture.

An email address. The form renders an email input and checks the address format. A report shows the value as a mailto: link.

A whole number. Add min: and max: to bound it.

seats int required "Seats" {
min: 1
max: 500
}

An amount, stored as whole minor units. A price of 12.50 euros is stored as 1250.

There is no floating-point number anywhere in the data model. min: and max: on a money column are in minor units too, so min: 500 is five euros. This is different from decimal, whose bounds are in its own units.

The form accepts the viewer’s locale notation: 12.50 in English, or 12,50 in German. A report shows the formatted amount.

A number with decimal places. Write the number of places in parentheses, from 1 to 4.

raw_points decimal(1) "Raw points" {
min: 0
max: 20
}
pass_mark decimal(2) "Pass mark (%)" {
min: 0
max: 100
default: 50.5
}

The engine stores the number as a whole number: 14.5 in a decimal(1) is stored as 145. You never write the stored number. min:, max: and default: are in the column’s own units, so max: 20 is 20.0 and default: 50.5 is 50.50. A bound or a default with more places than the column has is a compile error.

The form accepts the local spelling: 14.5 under en and 14,5 under de, fr, es, pt and tr. It refuses a number with more places than the column has, such as 14.55 in a decimal(1), and does not round it. It refuses a number outside min: and max:, and the message shows the bound as you wrote it: “At most 20.0.” A report, a record, a sheet and an export show every place: a decimal(2) shows 9.50, not 9.5. An Excel export writes a number with its places and no currency sign.

The compiler refuses decimal without places, decimal(0) (use int) and more than four places. A decimal has no currency, so it is not a replacement for money.

A hook reads and writes the stored whole number: 145 for 14.5, as it reads money in cents.

To change an int column into a decimal, say what its stored numbers meant with retype.

A calendar date, stored as YYYY-MM-DD. A date has no time and no time zone.

One instant, stored in UTC with a Z suffix. The engine normalizes the value on write.

Storage is always UTC. The time zone is a question about display and about input, and never about storage. Text order is therefore chronological order, so a report can sort on the column directly.

The form renders a datetime-local control, which carries no offset. The engine reads that value in the time zone of the page, and shows a stored instant in the same time zone. A submitted value that does carry an offset is converted from that offset, and consults no time zone. See Set the time zone.

True or false, stored as 0 or 1. The form renders a checkbox.

A closed set of values that you name in the declaration. Each member has a value and a label.

status enum(draft "Draft", active "Active", closed "Closed") required "Status"

The form renders a select. A report shows the label and never the stored value. The database rejects any value that is not a member.

A long list of values does not fit on one line. Write enum without parentheses and put the values in the column’s block instead, one value and its label per line:

missed enum required "Not completed" {
no "Completed"
excused "Absent, excused"
unexcused "Absent, unexcused"
makeup_pending "Make-up pending"
cheating "Cheating"
default: no
}

This column is the same as missed enum(no "Completed", excused "Absent, excused", …) required "Not completed" { default: no }. The database, the form and the report do not change. The values keep the order of their lines. Properties such as default: and help: can stand before, between or after the values. Flags such as required stay after the word enum.

A value line holds a value and its label, and nothing else. The compiler refuses these, and each message gives the repair:

  • values in enum(...) and in the block of the same column;
  • enum without parentheses and with no value line;
  • a value line in the block of a column that is not an enum;
  • a value line without a label, or with a flag after the value;
  • a value line named like a property of the block, such as default "no". The compiler reads it as a property without its colon. Write a value with that name in enum(...);
  • the same value twice, in either form.

The select also carries an empty option. To name it, see empty_label.

The select does not offer a row in a gone state. A record that already points at one keeps it. See state.

A reference to one row of another table.

fee_group ref(fee_groups) required "Fee group"

The form renders a select over the target table’s display columns. A report shows the target’s display value.

The select also carries an empty option. To name it, see empty_label.

The database column is named <name>_id. In .mtd you always write the logical name.

A reference to many rows of another table. The engine owns a junction table for it, and you never name that table.

tags multi(tags) "Tags"

The form renders a checkbox list. The list does not offer a row in a gone state, but a record keeps the ones it already holds. A multi is a set of rows and not a value, so it cannot be a column in a report and cannot be a cell in a sheet. To ask a question about it, use count(...) or exists(...).

The other side of a reference that already exists.

posts list(posts.author) "Posts"

A list is not stored and never appears in a form. Like a multi, it is a set of rows. A detail region can show one, because a record layout has room for a list of links.

The other side of a unique reference: the one row of another table that points at this row.

report_grade one(report_grades.enrolment) "Report grade" {
where: status in (decided, confirmed_by_conference)
}

The argument names the other table and its ref back to this table. That ref must be unique on its own, as a flag or as a one-column unique(...). If it is not, the compiler refuses the column and tells you to declare it unique or to use a list. The ref must not be sensitive.

A one is not stored and never appears in a form. It holds at most one row, and it is empty when no row points here.

  • In an expression, a path steps through a one as it steps through a ref: report_grade.points >= 5, or report_grade.decided_by.name. The step counts as one of the four references a path may walk. To ask whether there is a row, write report_grade.id is empty. The one on its own is a row and not a value, so report_grade is empty is refused.
  • In columns:, sort: and a detail’s fields:, the one on its own shows the other row’s display, like a ref does. A path through it is refused there. A one is not in the default columns of a report or a detail.
  • In a matrix cell:, write <one>.<column> to show one stored column of the other row: cell: report_grade.points. See matrix.

A one cannot be a filter:, search:, readonly:, group_by: or body: entry, a sheet column, a matrix axis label:, group: or sort:, or a {:…} value.

where: and gone: mean what they mean on a count. A row for which where: is not true counts as absent, and so does a row in a gone state unless the column says gone: show. The condition is about the other table’s row. It may not read a sensitive column, because every reader of the column sees whether a row was found. These are the only two properties of a one. It takes no required, unique or sensitive flag.

A one stores nothing, so it adds no sensitivity and removes none. Reading report_grade.points reads report_grades.points, so a role needs grants: report_grades.points, the same grant a report of report_grades needs. A role without it does not get the column, and a matrix whose cell it is does not appear for that role.

If the other table is scoped, the lookup finds a row only in the current scope, as a count over that table does. A public page may not show a one into a scoped table.

Reading through a one does not apply the page access rules of the other table. This is the same for a ref path and for an aggregate: the page that shows the row decides who reads it. An aggregate column is a property of the row, so it counts or adds every related row, whatever the reader’s row filter admits. A region that reads rows, such as a chart, does apply the page’s row filter. To add up only the rows that the reader may read, group a report. See Show totals per month.

A derived column is computed per query. It is read-only, it never appears in a form, and it has no column in the database. Because the engine compiles it to SQL, a report can sort and filter on it like any stored column.

How many rows of another table point at this row.

signups count(event_signups.event) "Signups"

A count has no empty:. A count of no rows is 0.

unexcused count(absences.student) "Unexcused absences" {
where: excused = false
}

where: counts only the related rows for which the condition is true. “How many are unexcused” is then a column, and not a second region. The condition is an expression about the related rows: excused above is a column of absences. It cannot read a column of the row that holds the count. It can read :user.…, today and now.

all_comments count(comments.post) "Comments, deleted ones included" {
gone: show
}

A count, sum, min or max leaves out the related rows that are in a gone state, as a list does. So count(comments.post) does not count a comment in a removed gone state, and the count agrees with the list of comments. Write gone: show to include those rows. show is the only value.

The compiler refuses a where: that names a gone state of the related rows unless the column says gone: show. It also refuses gone: show when the related table has no gone state.

where: and gone: are the only properties of a count. The compiler refuses empty:, weight:, min: and max: on a count, and the message gives the reason for each.

An aggregate over a column of related rows. sum adds the values up, and min and max take the smallest and the largest value.

total sum(order_lines.order.amount) "Total" {
empty: zero
}

Inside the parentheses, first name the related rows. Write a list or multi column of this table, such as marks, or a table and its reference back to this table, such as order_lines.order. When this table has a list or multi column with the same name as a table, the column is used. Any other column with that name, such as a second count, does not hide the table. Then name the column to aggregate. The path can go through a ref of the related rows, for example sum(marks.assessment.weight).

Property Values Effect
empty: null or zero. Required. the value for a row with no related rows. null shows an empty cell, and zero shows 0
where: a condition aggregates only the related rows for which it is true. It works as on a count
gone: show includes the related rows in a gone state, which are left out by default. See gone
weight: a path to a column multiplies each value before it is aggregated. See weight
min: / max: whole numbers from 0 to 4503599627370496 the range of the result, which the compiler uses to check arithmetic on the column. See Whole numbers and overflow. Refused when the aggregate reads a decimal: declare the range on that column

The aggregate of a decimal column is a decimal with the same places, and a report shows it with them. With a weight:, the places of the weight are added: an int weight keeps them, and a decimal(1) weight adds one.

The aggregate of a money column is money. A sum, min or max shows as an amount, such as €12.50 or 12,50 €, in a report, a record, a matrix, a sheet and a grid, not as the 1250 cents the row stores. A CSV export writes 12.50, and an XLSX export writes the number with the money format, as for a stored money column. An int weight: keeps this. A decimal weight does not: the result is then a number with places and no currency. Sorting, a filter: value, min: and max:, and expressions all use the stored cents, so a filter for the amount 12.50 is ?total=1250. A computed column that you declare int over money stays an int, and so does its sum: declare it money to show amounts.

empty: is required because SQL answers “no rows” with no value, and “no marks yet” is not the same as “zero points”. The compiler refuses an aggregate without empty:, and any value other than null or zero.

Arithmetic is integer only. Division is not an operator: use ratio(...) inside exactly one round(...).

points_written sum(marks.points) "Points × weight, written" {
where: assessment.area = written
weight: assessment.weight
empty: null
}

weight: names a column of the related rows, or a path through their ref columns. Each value is multiplied by the weight of its row before the aggregate adds it up. So the example is the sum of points × weight over the written marks. On min and max, the engine takes the smallest or the largest product.

A weighted average is two sums and one division: the weighted sum above, divided by sum(marks.assessment.weight) over the same rows. See ratio.

The compiler refuses a path that does not exist. A count has no weight:, because a count reads no value.

A column with a value: is a computed column. The engine calculates the value from other columns of the same row each time it reads the row.

places_left int "Places left" { value: capacity - signups }
full bool "Full" { value: signups >= capacity }

The value is an expression. It can read the columns of the row, the rows that its ref columns point to, other computed columns and aggregates, :user.…, today and now. It cannot read :route.…, a data row or a var.

Write the type that the value has: int for a whole number, decimal(n) for a number with places, bool for a condition. A computed bool is a named condition. See Named conditions.

For a number, the compiler brings the value to the places of the column. A value with fewer places is multiplied exactly. A value with more places is a compile error, and the message shows the round(...) to write. An average into a decimal(2) keeps its decimal point:

points_total sum(marks.points) "Points" { empty: null }
mark_count count(marks) "Marks"
average decimal(2) "Average" {
value: round(ratio(points_total, mark_count), scale: 2, ties: up)
}
marks list(marks.student) "Marks"

The same round(..., scale: 2, ...) into an int column stores the average × 100, such as 950 for 9.50. That still works, and the compiler warns and suggests decimal(2). For other types, the compiler does not compare the type with the value yet.

A computed column has no column in the database. A report can show, sort, filter and export it like a stored column. A form or a set cannot write it.

The compiler refuses these:

You write Reason
value: and default: on one column a value calculated on every read has nothing to default to
value: and derived the engine calculates the value, so no hook writes it
value: and versioned a computed column has no saved values to keep
a value that reads its own column, directly or through other computed columns the calculation has no end
the column in a form’s fields:, or in a set a calculated value cannot be written
a value that reads a sensitive column, on a column that is not sensitive see Sensitive columns are granted per role

The engine writes these columns. A form never accepts one from a request, even if the request names it.

A readable address derived from other columns.

slug slug(title) "Address"

The engine derives the value, normalizes it, and reserves it. A slug is unique against live values and against retired ones, so an address never points at a different row later.

A slug with no source list derives from the table’s display:. A ref item of the display contributes the text it shows, which is the display of the row it points to, not that row’s number. A coalesce(a, b) item contributes the first column that has a value. A table with display: person, team gives the address mueller-anna-red-team, not 1-1. A slug with a source list, such as slug(title), reads those stored columns as they are.

A slug does not change when its source changes. A URL that changes by itself is a broken link that somebody else is holding. This includes a renamed row that a ref points to: the address was written once, when the row was created.

A random token for an address that is hard to guess, such as a private share link.

share_token unguessable "Share link"

The engine generates the value at insert. The alphabet has 32 symbols and drops the four letters that are misread on paper. A miss on a route bound by an unguessable is rate limited per tenant and per client.

A picture. The engine stores the file beside the tenant database and keeps the facts about it in seven columns.

photo img optimized "Photo" {
max_mb: 5
max_px: 1024
accept: jpeg, png
alt: caption
}

An upload is re-encoded from its decoded pixels. The engine applies the EXIF orientation and drops everything else. The engine also makes a thumbnail of 320 pixels on the longest edge.

Before it decodes a file, the engine reads the size that the file’s header declares. It refuses a picture of more than 50,000,000 pixels, or with an edge of more than 12,000 pixels. The field then shows “The image has too many pixels. Choose a smaller version.”

Without optimized, the engine keeps the resolution. A JPEG stays a JPEG and a PNG stays a PNG. A WebP is stored as a JPEG, and a WebP with transparent pixels as a PNG. The engine writes a JPEG at quality 82.

With optimized, the engine makes the picture smaller to max_px: and stores it as a JPEG at quality:. A picture with transparent pixels is stored as a PNG, because a JPEG cannot hold transparency.

The formats that an upload can have: jpeg, png and webp, separated by commas. The default is all three. The engine reads the format from the file’s bytes, not from its name or from the browser. A file in another format refuses the upload with “This image format is not accepted. Allowed formats: JPEG, PNG.” A file that is not a picture refuses it with “This file is not an image. Allowed formats: JPEG, PNG.”

The compiler refuses any other word. It refuses avif with its own message, because the engine cannot decode AVIF.

The largest upload, in megabytes of 1,048,576 bytes. It takes a whole number from 1 to 100. The default is 10. A larger file refuses the upload with “The image is too large (at most 5 MB).” The limit applies to the uploaded file. The organization’s storage quota is a separate limit.

alt: names a column of the same table whose text describes the picture. In a detail region, the picture’s alternative text is the text of that column, when the region shows the column and the column has a value. Otherwise it is the row’s display value. There is no default column.

The compiler refuses a column that the table does not have.

These two properties need optimized:

Property Values Default Effect
max_px: 16 to 8192 2048 the longest edge of the stored picture, in pixels. A smaller picture is not made larger
quality: 1 to 100 82 the JPEG quality of the stored picture and its thumbnail

The compiler refuses a value outside the range. On an img without optimized it refuses both properties, and the message shows the column with optimized added.

photo img optimized "Photo" { keep_original: true }

keep_original: true also keeps a copy at the full resolution of the upload. The copy is also re-encoded: it is a JPEG at quality 82, or a PNG for a picture with transparent pixels. It is never the file that the browser sent. The default is false.

No page links to the copy. Its address is the picture’s address with .orig after the digest. Access to it is authorized by the row, like the picture.

The compiler refuses any value other than true or false, and refuses keep_original: on an img without optimized.

CAUTION: A backup of a tenant is two things. Copy the database file and the blob directory together. An organization that resets itself every night has a third: its stored template, which is a database file and a blob directory of its own.

A document. The engine stores the file beside the tenant database and keeps the facts about it in five columns: the digest, the file name, the type, the size and the time of the last change. A file column holds one document per row. It has no width and no height.

receipt file required "Receipt" {
accept: pdf, jpeg, png, webp
max_mb: 10
}

The engine decides the type of an upload from the file’s bytes, not from its name or from the browser. A PDF must start with %PDF-1. or %PDF-2., with only a byte-order mark and white space before it, and it must end with %%EOF and a startxref offset that lies inside the file. The engine does not read the rest of a PDF, and it does not decompress it. A PDF that is encrypted is accepted, because the engine cannot look inside it.

A PDF is stored as it arrived. Its author, its producer and the photographs inside it stay in the file. The form says so under the control.

A JPEG, a PNG or a WebP is not stored as it arrived. It goes through the same steps as an img upload: the engine applies the EXIF orientation, drops the rest, including the GPS position, and stores a JPEG or a PNG at the resolution of the upload. A photograph of a receipt keeps no thumbnail.

The file is served only as a download. The address of a file is authorized by the row that owns it, like the address of a picture. A row that a person cannot see gives 404. The response says Content-Disposition: attachment, whatever the address asks for, and it says Content-Security-Policy: sandbox; default-src 'none' and Cache-Control: private, no-store. No page shows a preview of a file.

In a report, a list or a detail, a file shows as its name, its type and its size, for example “receipt-march.pdf — PDF, 1.2 MB”. The name is a link that downloads the file. A file column cannot be sorted, filtered or searched.

In a form, a file column is a file input. When the row has a file, the form shows its name as a link and a “Remove file” box. The box is not shown when the column is required.

CAUTION: MatterData does not scan a file for viruses, and it does not remove scripts from a PDF. See A file is downloaded, never displayed.

Types and size of a file: accept and max_mb

Section titled “Types and size of a file: accept and max_mb”

accept: lists the types that an upload can have, separated by commas: pdf, jpeg, png and webp. The default is all four. On a column with accept: pdf, jpeg, a file of another type refuses the upload with “This file type is not accepted here. Accepted: PDF, JPEG.” A photograph in the HEIC format refuses it with “HEIC photos are not accepted. Save the photo as JPEG or choose a PDF.”

The compiler refuses any other word, and each refusal gives its reason:

Word Reason the compiler gives
docx, xlsx, pptx, odt, ods, odp Office documents are not accepted yet
doc, xls, ppt a legacy Office file is the classic carrier of macros
docm, xlsm, pptm a macro-enabled Office file runs code when it is opened
rtf RTF can embed OLE objects
svg, html the file runs scripts in the origin that shows it
zip, exe the engine cannot say what is inside, or it is an executable
gif, heic, avif use img for a picture that is shown; the engine has no decoder for HEIC or AVIF

max_mb: is the largest upload, in megabytes of 1,048,576 bytes. It takes a whole number from 1 to 50. The default is 10. A larger file refuses the upload with “The file is too large (at most 10 MB).” The organization’s storage quota is a separate limit.

The forms of one page share a limit of 63 MB for all their img and file uploads together. The compiler refuses a page whose forms declare more, and names the columns.

A large upload gets more time than an ordinary request. The window is 30 seconds plus one second for each 256 KiB of the upload, and at most 5 minutes. A 20 MB PDF has 110 seconds. The longer window applies only to a person the page admits, and only after the engine has identified them.

The compiler refuses these declarations and gives a repair:

  • optimized, alt:, max_px:, quality: and keep_original:. A file is not re-encoded. Use img for a picture that is shown.
  • default:, min:, max:, unique, derived, versioned and sensitive.
  • A file column in the columns: of a sheet, and a file column as a sort:, filter: or search: entry.
  • A file column in a form that a visitor without a login can open.

retention ... on <file column> is refused, as it is for an img. Write a retention rule for the row instead.

A file column holds one document. To attach several, make a table for the files with a ref to the record and a file column, and show it in a list region. See Attach files to a record.

A modifier is an adjective and takes no value. A property takes a value and is written inside braces. sensitive(<class>) is the one modifier with an argument: the argument is a name for a group of columns, not a value of the column.

Modifier Effect
required The column must have a value.
unique No two rows can hold the same value.
sensitive Only a role whose rule grants the column can read or write it. See Sensitive columns are granted per role.
sensitive(<class>) The same as sensitive, and the column is in the named sensitivity class. A grant of the class grants the column. See Sensitivity classes.
optimized An img is made smaller and stored as a JPEG. See img. The compiler refuses it on any other type.
derived The table’s before insert or before update hook writes the column. See Mark a column that the hook writes.
versioned The table keeps a version of the column at every save that changes it. See versioned.

There is no readonly modifier. To show a column in a form without a control, list it in the form’s readonly: property. See form.

Property Effect
default: The value for a new row. The value depends on the type. See default.
label: The label of the column. It is a second way to write the label at the end of the line. When a column has both, label: is used.
min: / max: Bounds for a number, or a length for text. Other types refuse them. See Value and length bounds.
help: One sentence shown with the control.
rows: The height of the textarea, in lines: a whole number from 1 to 100. It has an effect on long text (default 5) and on markdown (default 12).
value: The expression that calculates a computed column. See value.
empty: Required on sum, min and max: null or zero. The value when there are no related rows.
where: On an aggregate: the related rows to include. See where.
gone: On an aggregate: show includes the related rows in a gone state. See gone.
weight: On sum, min and max: a column that multiplies each value. See weight.
empty_label: The text of the empty option in a select. enum and ref only.

A form can give label:, help:, rows:, min:, max: and empty_label: a different value for one page, in its field block. See form. A form cannot change default: or value:, because they are data.

The properties of img, file and markdown are in the sections of those types.

A column without a label shows its name.

default: is the value that a new row gets when the form or the write does not give one. A form that creates a row shows the value in the control.

Type Value
text, long text, markdown, email a quoted text: default: "Guest"
int, money a whole number: default: 0. On money it is in minor units
decimal(n) a number with at most n places, in the column’s units: default: 1.5
bool true or false
enum a member: default: active
date today, or a quoted date: default: "2026-01-31"
datetime now, or a quoted time in UTC: default: "2026-01-31T18:30:00Z"

The compiler refuses these, and the message names the repair:

  • a value of the wrong kind, such as an unquoted word on a text column, or now on a date;
  • a number with a decimal point, such as 1.5, on an int or money column, and a number with more places than a decimal column has;
  • a datetime with an offset. The message shows the same time in UTC;
  • a default: on a slug, unguessable, img, list or aggregate column;
  • a default: beside a value:.

The properties min: and max: limit what a form accepts.

Type Meaning
int, money The smallest and largest value. On money the numbers are in minor units
decimal(n) The smallest and largest value, in the column’s own units
text, long text, markdown, email The shortest and longest text, in characters
sum, min, max The range of the result. See sum, min and max

The compiler refuses min: and max: on any other type, and also in a field block for such a column. The message names the column and the repair. Before this check the line was accepted and had no effect.

  • On a date, remove the line and add a table rule: check starts_on >= today "Pick a day that is not past.". A rule compares a date with today or with another date column. It cannot compare with a written date.
  • On a datetime, use the same rule with now: check opens_at is empty or opens_at >= now "...".
  • On an enum, list fewer members. An enum holds only its members.
  • On a ref, a table rule can narrow the rows that are allowed.
  • On a bool, remove the line. A bool has two values.

Every select carries an empty option. In an English app it reads Please choose. Use empty_label: to say what the empty value means.

alliance ref(alliances) "Alliance" { empty_label: "Whole kingdom" }

The property changes one string. It adds no enum member, and it stores no value. An empty value stays empty.

empty_label: applies to enum and ref. These are the two types that render a select. On any other type the compiler refuses it and names the type you wrote.

The column must be optional. On a required column the compiler refuses empty_label:, because the empty option can never be saved. If the empty value has a meaning, drop required from the column.

A form can name the empty option differently for one page:

form of events {
fields: title, alliance
field alliance { empty_label: "All alliances" }
}

The form’s text wins on that page. The column’s text holds on every other page.

The text renders in a form select only. A report cell, a detail cell and an export are unchanged. An export keeps the empty cell, because a spreadsheet reads an empty cell as no value.

A versioned column keeps a version at every save that changes it. A version holds the values of all of the table’s versioned columns after the save, the time of the save, and who saved it.

table posts "Posts" {
title text required versioned "Title"
body markdown required versioned "Body" { max_kb: 256 }
}

The record itself is updated as before. Reports, filters, sorting, exports, rules, and computed columns read the record and do not change. The newest version always holds the same values as the record.

  • A new record gets its first version.
  • A save that changes a versioned column adds a version. A save that changes none adds nothing.
  • Saves by one person within 10 minutes are one version. The later save replaces the newest version. A save by a visitor without a sign-in never does this, and neither does a save that finds the record in a different lifecycle state from the newest version.
  • A record written outside the engine gets a version at its next save.
  • Deleting a record deletes its history.

Show the history with a versions region.

The compiler refuses versioned on these columns, and the message names the repair:

Refused Reason
an aggregate, list, multi, img, slug, or unguessable a save does not write one value into the record
a column with value:, derived, or sensitive a computed column has no saved value, a hook rewrites a derived one, and a sensitive one’s history would need its own grant
the lifecycle column, or the scope’s column the engine writes them, and every version records the state already
a column named row_id, saved_at, saved_by, state, or present the history table uses these names
a column that a retention … on rule clears the history would keep what the retention erases

versions keep says how much history each record keeps. It is optional and appears once in a table block. Without it, a table with a versioned column keeps the 20 newest versions of each record.

table posts "Posts" {
title text required versioned "Title"
versions keep 20 within 1y
}
Statement Keeps
versions keep 20 the 20 newest versions of a record, from 1 to 200
versions keep 90d the versions of the last 90 days, and at most 200
versions keep 20 within 1y at most 20, and none older than a year

A version is removed when it passes either limit. The newest version is never removed, because it is the current value. The count is applied when a record is saved. The age is applied by the nightly retention run and uses the windows of retention: d, m, and y.

The history is stored in a table the engine owns, <table>_versions, in the organization’s file. Its size shows on the usage page at /matterdata/usage as Version history, apart from the picture quota.

A change that removes history needs an acknowledgement at the deploy:

Change Acknowledgement
stop versioning one column, and keep the column drop versions of body !destructive "Reason" in the table
drop a versioned column drop body !destructive "Reason" covers the column and its history
keep less: a smaller count, or a new or shorter age retention posts_versions !destructive "Reason" in the app block

Versioning a column of a table that already has records writes one version per record at the deploy, with its current values. Versioning a second column adds it to later versions; older versions do not hold it, and restoring one of them keeps that column’s current value.

Website privacy policy