You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
858 B

defmodule DecentralisedBookIndex.Metadata.Publisher do
use Ash.Resource,
otp_app: :decentralised_book_index,
domain: DecentralisedBookIndex.Metadata,
data_layer: AshPostgres.DataLayer
require Ash.Query
alias DecentralisedBookIndex.Metadata
postgres do
table "publishers"
repo DecentralisedBookIndex.Repo
end
actions do
defaults [:read, :update, :destroy]
create :create do
primary? true
accept [:name]
end
read :by_id do
argument :id, :uuid, allow_nil?: false
get? true
filter expr(id == ^arg(:id))
end
end
attributes do
uuid_primary_key :id
attribute :name, :string do
allow_nil? false
public? true
end
timestamps()
end
relationships do
belongs_to :dbi_server, Metadata.DBIServer
has_many :books, Metadata.Book
end
end