Laizy CMS
Schema

Schema Syntax

Complete reference for the .laizy schema language — models, fields, types, and constraints.

Schema Syntax

Laizy schemas use a block-style syntax inspired by Prisma. Schema files use the .laizy extension and live in your laizy/ directory by convention.

Models

A model defines a content type. Each model becomes a database collection, a TypeScript interface, and a section in the dashboard.

model BlogPost {
  title: String { required: true }
  content: String { required: true }
  slug: String { unique: true }
}

Model names must be PascalCase and unique within a schema file.

Fields

Each field has a name, a type, and optional constraints inside curly braces.

fieldName: FieldType { constraint: value }

Field names must be camelCase. Fields without constraints don't need curly braces:

model Author {
  name: String { required: true }
  bio: String
}

Field Types

TypeTypeScript EquivalentDescription
StringstringText content of any length
IntnumberWhole numbers (no decimals)
FloatnumberDecimal numbers
Booleanbooleantrue or false
DateTimeDateISO 8601 timestamps

Constraints

Constraints control validation and behavior for each field.

required

Makes the field mandatory when creating content.

title: String { required: true }

unique

Enforces uniqueness across all content entries of this model.

slug: String { unique: true }
email: String { required: true  unique: true }

default

Sets a default value when the field is not provided.

status: String { default: "draft" }
viewCount: Int { default: 0 }
published: Boolean { default: false }

maxLength

Limits the character count for String fields.

title: String { maxLength: 200 }
excerpt: String { maxLength: 500 }

Multiple constraints

Constraints can be combined on a single field. Each constraint goes on its own line inside the curly braces:

model Product {
  name: String {
    required: true
    maxLength: 200
  }

  sku: String {
    required: true
    unique: true
    maxLength: 50
  }

  price: Float {
    required: true
  }

  inStock: Boolean {
    default: true
  }
}

Complete example

Here's a full schema with multiple models and relationships:

model BlogPost {
  title: String {
    required: true
    maxLength: 200
  }

  content: String {
    required: true
  }

  slug: String {
    required: true
    unique: true
  }

  status: String {
    default: "draft"
  }
}

model Author {
  name: String {
    required: true
    maxLength: 100
  }

  email: String {
    required: true
    unique: true
  }

  bio: String
}

model HeroSection {
  badge: String
  headline: String
  subheading: String
  ctaPrimary: String
  ctaSecondary: String
}

File location

By default, the CLI looks for schema files at laizy/schema.laizy. You can change this in your ~/.laizyrc configuration:

{
  "schemaPath": "content/schema.laizy"
}

On this page