Models & Schema · Overview
Models & Schema
A model in Underpeaks Core is a schema definition for one table: its name, its columns, and how those columns behave. Every table the public API can read or write — and every table the console content editor renders — is described by one of these definitions.
Anatomy of a model
{
"table_name": "nxf_product",
"schema": "public",
"columns": [
{
"name": "prod_id",
"type": "string",
"nullable": false,
"is_primary": true,
"hidden": true
},
{
"name": "title",
"type": "string",
"nullable": false,
"hidden": false,
"ui_type": "textfield"
},
{
"name": "price",
"type": "double",
"nullable": false,
"hidden": false,
"ui_type": "currency-input"
}
],
"constraints": []
}
| Key | Required | Description |
|---|---|---|
table_name | Yes | The underlying table name. |
schema | No | The database schema. Defaults to public. |
columns | Yes | The model's fields — see Field Types. |
constraints | No | Table-level constraints (composite unique keys, table-level foreign keys). |
Common system columns
Most models share the same shape for their non-content columns:
| Column | Type | Notes |
|---|---|---|
<name>_id | string | Primary key (is_primary: true), hidden: true |
project_id | string | Foreign key to the owning project, hidden: true |
tenant_id | string | Foreign key to the owning tenant, hidden: true |
created_at | datetime | hidden: true |
updated_at | datetime | hidden: true |
Any column marked hidden: true is stripped from every response returned by the public API — it never leaves the server. This is how internal columns like project_id, tenant_id, or a password_hash stay out of API responses without needing separate serialization logic.
Next steps
- Field Types — every column option, in detail
- Relationships — linking models with foreign keys