Content schema representing content instances.
Content stores field values as a JSONB map keyed by field IDs. Each content instance belongs to a schema and contains field data according to that schema's field definitions.
This module is primarily used internally by Plato. Use the Plato module for
content queries and management instead.
Internal Structure
Content is stored with:
schema_id- Reference to the schema this content belongs tofield_values- Map of field_id => value pairs stored as JSONB
Field values are stored with string keys (field IDs) and can contain:
- Simple strings for text fields
- Maps for image fields (with url, storage_path, etc.)
- Integer IDs for reference fields (resolved by ContentResolver)
Example Field Values
%{
"1" => "Blog Post Title",
"2" => "This is the post body...",
"3" => 42, # Author ID (reference field)
"4" => %{ # Image field
"url" => "...",
"storage_path" => "...",
"filename" => "..."
}
}
Summary
Functions
Creates a changeset for content.
Types
@type t() :: %Plato.Content{ __meta__: term(), field_values: map(), id: integer() | nil, inserted_at: DateTime.t() | nil, schema: term(), schema_id: integer(), updated_at: DateTime.t() | nil }
Functions
Creates a changeset for content.
@spec create(map(), module()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}