Shortcut DSL for attributes and relationships in Ash resources.
| DSL | allow_nil? | public? |
|---|---|---|
attribute (Ash) | true | false |
req | false | true |
req_prv | false | false |
opt | true | true |
opt_prv | true | false |
| DSL | allow_nil? | public? |
|---|---|---|
belongs_to (Ash) | true | false |
req_belongs_to | false | true |
req_prv_belongs_to | false | false |
opt_belongs_to | true | true |
opt_prv_belongs_to | true | false |
defmoduleMyApp.UserdouseAsh.Resource,extensions: [AshReqOpt]attributesdouuid_primary_key:id# Required attributesreq:email,:string# allow_nil?: false, public?: truereq_prv:password_hash,:string# allow_nil?: false, public?: false# Optional attributesopt:name,:string# allow_nil?: true, public?: trueopt_prv:last_login_at,:utc_datetime# allow_nil?: true, public?: false# Original attribute macro still worksattribute:nickname,:string,allow_nil?: trueendrelationshipsdo# Required relationshipsreq_belongs_to:company,Company# allow_nil?: false, public?: truereq_prv_belongs_to:created_by,User# allow_nil?: false, public?: false# Optional relationshipsopt_belongs_to:manager,User# allow_nil?: true, public?: trueopt_prv_belongs_to:updated_by,User# allow_nil?: true, public?: false# Original belongs_to macro still worksbelongs_to:department,Department,allow_nil?: trueendendAdd ash_req_opt to your list of dependencies in mix.exs:
defdepsdo[{:ash_req_opt,"~> 0.2.0"}]endMIT