Add the book eidtions registry to manage book editions.

This commit is contained in:
2025-03-08 21:40:15 +02:00
parent ee72055f81
commit 43e2e24fee
6 changed files with 252 additions and 0 deletions
+2
View File
@@ -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