mirror of
https://github.com/ash-project/ash_csv.git
synced 2024-09-20 21:32:48 +12:00
30 lines
614 B
Elixir
30 lines
614 B
Elixir
|
defmodule AshCsv.Test.Post do
|
||
|
@moduledoc false
|
||
|
use Ash.Resource,
|
||
|
data_layer: AshCsv.DataLayer
|
||
|
|
||
|
csv do
|
||
|
create? true
|
||
|
columns [:id, :title, :score, :public]
|
||
|
file "test/data_files/posts.csv"
|
||
|
end
|
||
|
|
||
|
actions do
|
||
|
read(:read)
|
||
|
update(:update)
|
||
|
create(:create)
|
||
|
destroy(:destroy)
|
||
|
end
|
||
|
|
||
|
attributes do
|
||
|
attribute(:id, :uuid, primary_key?: true, default: &Ecto.UUID.generate/0)
|
||
|
attribute(:title, :string)
|
||
|
attribute(:score, :integer)
|
||
|
attribute(:public, :boolean)
|
||
|
end
|
||
|
|
||
|
relationships do
|
||
|
has_many(:comments, AshCsv.Test.Comment, destination_field: :post_id)
|
||
|
end
|
||
|
end
|