udoschneider
Getting sorted relations from resource via code interface
All,
I’m currently struggling to sort relationships loaded from a resource.
E.g. a resource “Domain” has multiple “Controls”.
Getting a domain and preload the controls is easy and works just fine:
Domain.get_by_identifier!(identifier, load: :controls)
However I’m struggling with getting those controls as sorted list. My gut feeling is that this should be possible because the Api.load/3 function also accepts [atom() | {atom(), atom() | Keyword.t()}] as load_statement type. This would allow for something like
Domain.get_by_identifier!(identifier, load: [{:controls, [identifier: asc]}])
This doesn’t work though ![]()
Any pointers?
CU,
Udo
Most Liked
zachdaniel
Creator of Ash
This is done via passing a query as the value ![]()
Domain.get_by_identifier!(identifier, load: [controls: Ash.Query.sort(Control, identifier: :asc)]_
1
zachdaniel
Creator of Ash
For the most part, yes. Ultimately an action gets called on the destination resource that validates/authorizes whatever you’re doing. If you want to put it behind an action you can do it like this:
read :... do
prepare fn query, _ ->
Ash.Query.load(....)
end
end
1
Popular in Questions
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
I would like to know what is the best IDE for elixir development?
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Other popular topics
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I’m writing a test for one of the...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









