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
It looks like it’s finally safe to announce that Nerves supports Erlang/OTP 26 and Elixir 1.15!
We’ve updated dozens of Nerves and close...
New
AshCloak
AshCloak is small but mighty! Simply configure the extension, and it will encrypt your attributes :partying_face:
Since an exam...
New
Do you like Hacktoberfest? Also enjoy working with Nerves and want to contribute?
Fantastic! :tada: :beers:
Here are some potential sta...
New
First two Ash cookbooks are live! We’re still refining the format, so please give us your feedback, good or bad! The first two are: optim...
New
Livebook v0.7 is out! This is a major release coming with significant features in the following areas:
secret management
visual represe...
New
Hey folks!
AshEvents Release
We’ve just released the first version of AshEvents, an Event Sourcing tool for Ash Framework apps.
Check o...
New
We’re working hard on improving docs, and have some substantial things that it would be great to get some thoughts on.
One of the bigges...
New
This post introduces the new data features in Livebook 0.9: fast data exploration through integration with Explorer, interactive data tab...
New
Hi everyone,
We have just released Mime v2.0.4 with a potential security fix. Before this version, Mime.extensions("foo/bar+baz") would ...
New
Hey! For those following Hologram’s progress… I’m excited to share that I’ve just published the official roadmap for Hologram. You can ch...
New
Other popular topics
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
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
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
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
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









