podbox_ash/lib/podbox/podcast/resources/category.ex

46 lines
900 B
Elixir
Raw Normal View History

defmodule Podbox.Podcast.Category do
@moduledoc """
A podcast category
"""
alias Podbox.{Podcast, Repo}
use Ash.Resource,
data_layer: AshSqlite.DataLayer,
domain: Podcast,
notifiers: [Ash.Notifier.PubSub]
@type t :: Ash.Resource.record()
attributes do
uuid_primary_key :id
attribute :resource_id, :uuid, allow_nil?: false
2024-07-18 20:32:21 +12:00
attribute :name, :ci_string, allow_nil?: false, public?: true
attribute :domain, :ci_string, allow_nil?: true, public?: true
create_timestamp :inserted_at
update_timestamp :updated_at
end
actions do
defaults [:read, :destroy, create: :*, update: :*]
end
pub_sub do
module Podbox.PubSub
prefix "podcast:category"
publish :create, "created"
publish :destroy, "destroyed"
end
sqlite do
polymorphic? true
repo Repo
end
2024-07-18 20:32:21 +12:00
identities do
identity :unique_name, [:name]
end
end