August 2025
Intermediate to advanced
294 pages
6h 59m
English
There’s one last topic we want to cover before we finish up—it’s not related to what we’ve covered so far in this chapter, but we think it’s important. We’ve discussed little snippets about atomics all throughout this book but haven’t gone into much detail beyond the fact that they’re used for running logic in the data layer, instead of in our app. What does that actually mean, though?
Imagine we wrote a feature that counts the number of followers an artist has and manually updates the number whenever someone follows or unfollows them. It might look something like this, in the Tunez.Music.Artist resource:
| | update :follow do |
| | change fn changeset, _opts -> |
| | count = Ash.Changeset.get_attribute(changeset, ... |
Read now
Unlock full access