Overview
table() stores the columns. The key comes first, then each data type, then the options.
export const notes = table(
"notes",name { id: t.identity(),key title: t.text(),type published: t.boolean().default(false),after the type }, { … },options);
One builder
t is every builder. Import one builder when a file uses only that type.
The declaration
The list is how often you reach for each part while building. Columns, keys, and the calls come first.
import { index, table, t } from "okmodel/pg";
export const notes = table(
"notes",
{
id: t.identity(),
title: t.text(),
published: t.boolean().default(false),
},
{ indexes: (columns) => [index(columns.title)] },
);| Order | Page | You use it for |
|---|---|---|
| 1 | Columns | The builder for each value. |
| 2 | Keys | The primary key, and a unique. |
| 3 | Defaults | What fills a column you omit. |
| 4 | References | A foreign key. |
| 5 | Relations | The edge you query. |
| 6 | Queries | The calls on the table. |
| 7 | Traits | Shared columns, including timestamps and archive. |
| 8 | Indexes | An extra index. |
| 9 | Validation | The rule that rejects a bad value. |
| 10 | Shape | An array, a picklist, or an enum. |
| 11 | Filters | What a caller may send. |
| 12 | Presets | A named where. |
| 13 | Tenancy | The schema key, global, or a path. |
| 14 | Names | The SQL name, a previous name, and a comment. |
| 15 | Visibility | Hidden, sensitive, and guarded. |
| 16 | Checks | SQL the row must pass. |
| 17 | Required rows | Rows the application expects, inserted when the key is missing. |