Where is the best place for functions like (create/update)

Sorry I just started studying elixir/phoenix.
Where is the best place for functions like (create/update) in model or some custom module or something else.
Function for example:

def section_create() do
     changes = .....
     {:ok, result} =
       case Repo.get_by(Section, name: name) do
         nil  -> %Section{name: name, description: description}
         section -> section
       end
       |> Section.changeset(changes)
       |> Repo.insert_or_update
    {:ok, result}
   else
     err -> {:error, err}
 end

This repository of hex.pm is full of examples.
Edit: check the above linked file user.ex and the users.ex in the same directory.

1 Like