PhoenixKitOG.Templates (PhoenixKitOG v0.4.0)

Copy Markdown View Source

Context for managing OpenGraph templates. CRUD only — the editor and renderer live elsewhere.

Mutating functions accept an opts keyword list; pass actor_uuid: user_uuid to attribute the change in the activity feed. Omitting it logs an anonymous entry — still auditable, just not attributed.

Summary

Functions

Deletes a template. The foreign key cascades to every assignment that uses it, so each of those leaves its own assignment.deleted row (metadata "cascade" => "template.deleted"), written in the same transaction as the delete: the audit trail names exactly the assignments that went with it, or nothing at all when the delete rolls back.

Returns nil when no template matches.

Returns all templates, ordered by name.

Functions

change(template, attrs \\ %{})

create(attrs, opts \\ [])

@spec create(map(), keyword()) ::
  {:ok, PhoenixKitOG.Schemas.Template.t()} | {:error, Ecto.Changeset.t()}

delete(template, opts \\ [])

@spec delete(PhoenixKitOG.Schemas.Template.t(), keyword()) ::
  {:ok, PhoenixKitOG.Schemas.Template.t()}
  | {:error, Ecto.Changeset.t() | :not_found}

Deletes a template. The foreign key cascades to every assignment that uses it, so each of those leaves its own assignment.deleted row (metadata "cascade" => "template.deleted"), written in the same transaction as the delete: the audit trail names exactly the assignments that went with it, or nothing at all when the delete rolls back.

get(uuid)

@spec get(binary()) :: PhoenixKitOG.Schemas.Template.t() | nil

Returns nil when no template matches.

list()

@spec list() :: [PhoenixKitOG.Schemas.Template.t()]

Returns all templates, ordered by name.

update(template, attrs, opts \\ [])