Ash FrameworkAF
Ash Framework3y ago
12 replies
Robert Graff

Why don't read actions filter by attributes?

Given a read action
code_interface do
  define :read
end

actions do
  defaults [:read]
end


There are no arguments for the action, so the following does not select on email.
iex(21)> Membership.read(%{email: "tom@example.com"}, authorize?: false)
[debug] QUERY OK source="memberships" db=0.6ms queue=0.1ms idle=1341.0ms
SELECT m0."id", m0."role", m0."email", m0."invitation_token", m0."invited_at", m0."inserted_at", m0."updated_at", m0."organization_id", m0."user_id" FROM "memberships" AS m0 []


I would assume any filterable attributes would be automatically applied as a filter. You could also have an accepts option on the action to limit it certain filterable attributes.
Was this page helpful?