Add the book eidtions registry to manage book editions.
This commit is contained in:
@@ -24,5 +24,7 @@ defmodule DecentralisedBookIndex.Metadata do
|
||||
define :update_author_alias_registry, action: :update
|
||||
define :destroy_author_alias_registry, action: :destroy
|
||||
end
|
||||
|
||||
resource DecentralisedBookIndex.Metadata.BookEditionsRegistry
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,4 +33,8 @@ defmodule DecentralisedBookIndex.Metadata.Book do
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
relationships do
|
||||
belongs_to :book_editions_registry, DecentralisedBookIndex.Metadata.BookEditionsRegistry
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
defmodule DecentralisedBookIndex.Metadata.BookEditionsRegistry do
|
||||
use Ash.Resource,
|
||||
otp_app: :decentralised_book_index,
|
||||
domain: DecentralisedBookIndex.Metadata,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
postgres do
|
||||
table "book_editions_registries"
|
||||
repo DecentralisedBookIndex.Repo
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults [:read, :create, :update, :destroy]
|
||||
|
||||
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
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
relationships do
|
||||
has_many :authors, DecentralisedBookIndex.Metadata.Book
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user