zachdaniel

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 :slight_smile:

Where Next?

Popular in News & Updates Top

fhunleth
We’ve released new versions of all of the officially maintained Nerves Systems. The official systems, nerves_system_rpi0, nerves_system_b...
New
lawik
It is my pleasure to announce the official release of the new generation of NervesHub with the v2.0.0 release. Containers are tagged. :p...
New
bartblast
Hologram v0.10 is out! The headline is the event system, which got a lot bigger this release. You can now handle keyboard, scroll, resize...
New
zachdaniel
Hey folks! We’re starting a new weekly newsletter with the goings on of the various Ash packages and other interesting news from myself a...
New
fhunleth
We recently released Nerves 1.5.0 and corresponding updates to the Nerves new project generator, nerves_bootstrap and our official system...
New
hugobarauna
This post introduces the new data features in Livebook 0.9: fast data exploration through integration with Explorer, interactive data tab...
New
zachdaniel
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
fhunleth
We’re excited to announce that we’re actively working on NervesHub 2.0, an improved version of our IoT device firmware update and managem...
New
sorenone
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
zachdaniel
@jimsynz just launched an epic new extension for Ash! It allows you to create rich mix tasks for calling your resource actions directly f...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31013 112
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
joeerl
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
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement