Adding Helper Functions
Adding imports and aliases is a good start, but remember that .iex.exs is just a regular Elixir file, so you can define modules and functions as well. Consider the example we were just discussing: making a change to a record in the database. Normally, this process requires a few steps, but you can create a helper function that will handle most of the boilerplate for you.
We usually like to put our IEx helper functions into a single module. And, to help promote the laziness we’re trying to achieve, we like to give the module a very short name so it’s easy to type. We tend to use like names H or EH for “helper” or “Ecto helper”, respectively. Normally, these would be poor choices for module names, as they’re not descriptive ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access