Plato.Schema (plato v0.0.24)

Copy Markdown View Source

Schema definition for content types.

Schemas define the structure of content types in Plato CMS. Each schema has a name, can be marked as unique (singleton), and contains field definitions.

Managed By

Schemas can be managed in two ways:

Code-managed schemas appear as read-only in the admin UI.

Fields

  • name - Unique schema identifier (e.g., "homepage", "blog-post")
  • unique - If true, only one content instance allowed (default: false)
  • managed_by - Source of schema management ("ui" or "code")
  • fields - Associated field definitions

This module is primarily used internally. Use the Plato module and Plato.SchemaBuilder for schema operations instead.

Summary

Types

t()

@type t() :: %Plato.Schema{
  __meta__: term(),
  fields: term(),
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  managed_by: String.t(),
  name: String.t(),
  unique: boolean(),
  updated_at: DateTime.t() | nil
}

Functions

changeset(schema, attrs)

Creates a changeset for a schema.

create(attrs, repo \\ Plato.Repo)

@spec create(map(), module()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}