Execute Non-Database Operations with Multi
Learn how to execute non-database operations with Multi.
Using functions with Multi
Based on what we’ve seen of Multi
so far, it might appear that executing transaction
with functions has one clear advantage—functions allow us to run any Elixir code within the transaction. Recall our earlier example of updating a search engine within a transaction
call. Fortunately, Multi
offers this functionality as well. The run
function allows us to add any named or anonymous function as part of the Multi
. Here’s how we might add the search engine update logic we talked about earlier in this chapter.
Get hands-on with 1400+ tech skills courses.