Skip to content

Instantly share code, notes, and snippets.

@mxgrn
Created November 4, 2023 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxgrn/9ffcc6f26110a0d3043f04d9ff70e65c to your computer and use it in GitHub Desktop.
Save mxgrn/9ffcc6f26110a0d3043f04d9ff70e65c to your computer and use it in GitHub Desktop.
Book Ash Resource
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