BlogEngine.Authors (blog_engine v0.1.0)

Copy Markdown View Source

Tenant-scoped author commands and reads.

Explicit nil attribute policy

Attribute maps distinguish an absent key from a key whose value is nil.

  • An absent key never reaches the changeset.
  • An explicit nil clears the column only for the nullable optional fields [:title, :bio, :avatar_url, :host_identity_type, :host_identity_key].
  • An explicit nil for any other field — including the NOT NULL defaulted :active flag and the required :name and :slug — is ignored exactly as if the key had been omitted, so active: nil falls back to the schema default on create and leaves the stored value alone on update instead of raising a NOT NULL violation.

Summary

Functions

Creates a tenant-owned author.

Gets an author by tenant-scoped ID.

Gets an author by tenant-scoped slug.

Lists active authors ordered deterministically by name and ID.

Updates an existing tenant-owned author.

Functions

create(context, attrs)

Creates a tenant-owned author.

Explicit nil values follow the module's nil policy: they clear only the nullable optional fields and are otherwise ignored.

get(context, id)

Gets an author by tenant-scoped ID.

get_by_slug(context, slug)

@spec get_by_slug(BlogEngine.Context.t(), String.t()) ::
  {:ok, BlogEngine.Schema.Author.t()} | {:error, BlogEngine.Error.t()}

Gets an author by tenant-scoped slug.

list_active(context)

@spec list_active(BlogEngine.Context.t()) :: [BlogEngine.Schema.Author.t()]

Lists active authors ordered deterministically by name and ID.

update(context, id, attrs)

Updates an existing tenant-owned author.

Explicit nil values follow the module's nil policy: they clear only the nullable optional fields and are otherwise ignored.