Docs·UnderPeaks

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": []
}
KeyRequiredDescription
table_nameYesThe underlying table name.
schemaNoThe database schema. Defaults to public.
columnsYesThe model's fields — see Field Types.
constraintsNoTable-level constraints (composite unique keys, table-level foreign keys).

Common system columns

Most models share the same shape for their non-content columns:

ColumnTypeNotes
<name>_idstringPrimary key (is_primary: true), hidden: true
project_idstringForeign key to the owning project, hidden: true
tenant_idstringForeign key to the owning tenant, hidden: true
created_atdatetimehidden: true
updated_atdatetimehidden: 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