ElementorexCms.Ecto.Document (ElementorexCms v0.1.0)

Copy Markdown View Source

Ecto type for documents, stored as a map (jsonb in PostgreSQL).

schema "pages" do
  field :body, ElementorexCms.Ecto.Document, default: ElementorexCms.Document.new()
end

Casting accepts a map or a JSON string and normalizes it with the default registry (see ElementorexCms.Document.normalize/2), so whatever reaches the database is a valid, sanitized document.