August 2025
Intermediate to advanced
294 pages
6h 59m
English
To improve discoverability, we will add search to the Artist catalog to allow users to look up artists by name. What might it ideally look like, if we were designing the interface for this function? It’d be great to be able to call it like this:
| | iex> Tunez.Music.search_artists("fur") |
| | {:ok, [%Tunez.Music.Artist{name: "Valkyrie's Fury"}, ...]} |
Can we do it? Yes, we can!
A search action will be reading existing data from the database, so we’ll add a new read action to the Artist resource to perform this new search.
| | actions do |
| | # ... |
| » | read :search do |
| » | end |
| | end |
When we covered read actions in Defining a read Action, we mentioned that Ash will ...
Read now
Unlock full access