Is there an alternative way to select certain fields without using Ash.Query?

Currently I'm using it like:
MyApp.Domain.Resource
|> Ash.Query.limit(1)
|> Ash.Query.select([:slug])
|> Ash.read!()
MyApp.Domain.Resource
|> Ash.Query.limit(1)
|> Ash.Query.select([:slug])
|> Ash.read!()
But how am I going to use select in inside of read?:
actions do
read :read do
???
end
end
actions do
read :read do
???
end
end
Few of the attributes are public, include :slug
2 Replies
ZachDaniel
ZachDaniel3mo ago
prepare build(select: [:slug]) but also
prepare fn query, _ ->
Ash.Query.select(query, [:slug])
end
prepare fn query, _ ->
Ash.Query.select(query, [:slug])
end
I'd highly recommend reading the action guides, for each action type You can do a whole lot with actions
Jaeyson Anthony Y.
Jaeyson Anthony Y.OP3mo ago
Ah! I can see now where you were saying 🙏🏾 thanks for the advice!!!

Did you find this page helpful?