mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 21:43:12 +12:00
34 lines
628 B
Elixir
34 lines
628 B
Elixir
|
defmodule AshPostgres.Test.PostView do
|
||
|
@moduledoc false
|
||
|
use Ash.Resource, data_layer: AshPostgres.DataLayer
|
||
|
|
||
|
actions do
|
||
|
defaults([:create, :read])
|
||
|
end
|
||
|
|
||
|
attributes do
|
||
|
create_timestamp(:time)
|
||
|
attribute(:browser, :atom, constraints: [one_of: [:firefox, :chrome, :edge]])
|
||
|
end
|
||
|
|
||
|
relationships do
|
||
|
belongs_to :post, AshPostgres.Test.Post do
|
||
|
allow_nil?(false)
|
||
|
attribute_writable?(true)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
resource do
|
||
|
require_primary_key?(false)
|
||
|
end
|
||
|
|
||
|
postgres do
|
||
|
table "post_views"
|
||
|
repo AshPostgres.TestRepo
|
||
|
|
||
|
references do
|
||
|
reference :post, ignore?: true
|
||
|
end
|
||
|
end
|
||
|
end
|