Hey there,
I have been using https://hexdocs.pm/ecto/Ecto.Multi.html for a while now, and I was wondering what kind of convention do other people follow when they are naming the operations, especially when it is a Multi in an Enum.reduce/3.
With a regular Multi I usually use an atom as the examples do.
For a Multi in an reduce such as:
Enum.reduce(user_ids, Multi.new(), fn user_id, multi ->
blocked_user = Accounts.get_user_by_hash_id(user_id)
changeset = Block.changeset(%Block{}, user, blocked_user)
multi
|> Multi.insert("user_block_#{user.id}_#{blocked_user.id}", changeset)
end)
|> Repo.transaction()
I mostly use a string based on the structs I use, but this relies on both of them having an id and found.
Sometimes I use a uuid appended after the “user_block” for example, and in the docs I saw I could use a tuple.
How about you?