RaisFastRaisFast
Content Types

Overview

Define a database table in TOML and get a full CRUD API instantly — no code, no SQL.

Content Types is RaisFast's schema-driven data modeling system. You write a TOML definition, and the system does the rest:

  1. Auto-creates the database table with all columns and indexes
  2. Auto-generates a complete REST API (list / get / create / update / delete)
  3. Auto-wires validation, access control, caching, and relation resolution

The Flow

TOML Definition  →  Auto Migration  →  Auto API  →  Ready to Use
       ↓                  ↓                ↓
  Schema file      CREATE TABLE /      GET/POST/
  in extensions/   ALTER TABLE         PUT/DELETE

Minimal Example

Create extensions/content_types/portfolio.toml:

[content_type]
name = "Portfolio"
singular = "portfolio"
plural = "portfolios"
table = "portfolios"

[[fields]]
name = "title"
field_type = "text"
required = true

[[fields]]
name = "url"
field_type = "text"

[[fields]]
name = "cover"
field_type = "media"
media_config = { accept = ["image/*"], max_count = 1 }

[[fields]]
name = "description"
field_type = "text"

[[fields]]
name = "tech_stack"
field_type = "json"

[content_type.implements]
protocols = ["timestampable", "sortable"]

Start the server and you instantly get:

# List
curl http://localhost:9898/api/v1/cms/portfolios

# Create
curl -X POST http://localhost:9898/api/v1/cms/portfolios \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"My SaaS App","url":"https://mysaas.com","tech_stack":["Rust","React"]}'

Schema Header

The [content_type] section defines the content type identity:

FieldRequiredDefaultDescription
nameyesDisplay name
singularyesIdentifier, used as registry key and in API paths
pluralyesPlural form, used in API paths
tableyesDatabase table name
descriptionno""Description
slug_fieldnoField name to auto-generate slug from
kindno"collection""collection" (many records) or "single" (one record)
builtinnofalseIf true, default fields are not injected

Two Kinds

Collection

The default kind. Multiple records, full CRUD API:

[content_type]
kind = "collection"

Generates 5 endpoints: GET (list), GET /{id}, POST, PUT /{id}, DELETE /{id}.

Single

For one-record models (site settings, homepage config):

[content_type]
kind = "single"

Generates only 2 endpoints: GET (auto-creates on first request) and PUT (update the single record).

Where TOML Files Live

Content type definitions are loaded from:

extensions/content_types/*.toml

Built-in templates (blog, ecommerce) are also loaded automatically on first run.

What's Next

On this page