zachdaniel
Creator of Ash
Support for to-one relationship paths in calculations has been merged
Hey friends! A long time quality of life feature we’ve been wanting to add is the ability to refer to to-one relationships in calculations. Since an example is worth a thousand words, lets see how you would have had to refer to to-one related information in a calculation before:
The old way
Using a named aggregate
aggregates do
# add a `first` aggregate
first :authors_first_name, :authors, :first_name
end
calculations do
# refer to that in a calculation
calculate :some_calculation, :string, expr(authors_first_name ...)
end
Using in-line aggregates
# use an in-line first aggregate
calculate :some_calculation, :string, expr(first(author, field: :first_name))
The new way
The old ways will continue to work, but you can now use to-one path relationships directly in your calculations. You can’t use to-many relationships in a calculation, i.e posts.text in a calculation, because which post are you referring to?
calculate :some_calculation, :string, expr(author.first_name ...)
Hopefully this will make writing certain kinds of calculations much simpler ![]()
Popular in News & Updates
Hi folks,
For anyone following Hologram’s development or curious about running Elixir in the browser, I’ve created the Client Runtime Re...
New
NervesHub has had a CLI for a long time. It is called nerves_hub_cli and for the longest time you’d add it as a dependency. But only once...
New
Hey folks! Recording for my talk at Carolina Codes is up :slight_smile:
New
We have for you a new release candidate. Take :notes: if you use partitioned queues or make heavy use of Workflows. This is the RC for yo...
New
Hey folks! I’ll be teasing some interesting bits going into Ash 3.0 while I work on it, and this is post #1!
You can follow along with t...
New
Nerves, fwup and NervesHub have had delta updates as a feature on the checklist for a long time. A delta update being essentially a patch...
New
The second video from the Ash Primers series is out! https://www.youtube.com/watch?v=GtsL_lIis4Q This one is about the migration generato...
New
Hello everyone!
We’ve got two big updates on the Ash community today :tada:
Discord Support Forum → Elixir Forum
The Ash community is g...
New
Testing code destined for hardware can be tricky, but it just got one tiny bit easier!
:tty0tty was just released which is an Elixir por...
New
Hey friends! :wave:
With NervesConf 2024 around the corner, Frank, myself, and the greater Nerves team wanted to share a survey we’ve pu...
New
Other popular topics
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
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
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
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







