Created
November 4, 2023 16:24
-
-
Save mxgrn/9ffcc6f26110a0d3043f04d9ff70e65c to your computer and use it in GitHub Desktop.
Book Ash Resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule AshTable.Book do | |
use Ash.Resource, data_layer: AshPostgres.DataLayer | |
postgres do | |
table "books" | |
repo AshTable.Repo | |
end | |
attributes do | |
uuid_primary_key :id | |
attribute :title, :string | |
attribute :author, :string | |
attribute :year, :integer | |
timestamps() | |
end | |
actions do | |
defaults [:create, :read, :update, :destroy] | |
end | |
code_interface do | |
define_for AshTable.Library | |
define :create, action: :create | |
define :read_all, action: :read | |
define :update, action: :update | |
define :destroy, action: :destroy | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment