distributeaid / toolbox

DistributeAid Toolbox
http://distributeaid.org
GNU Affero General Public License v3.0
3 stars 1 forks source link

Retun either {:ok, _} or :not_found when calling Repo.get(id) #50

Open pedro-gutierrez opened 4 years ago

pedro-gutierrez commented 4 years ago

Is your feature request related to a problem? Please describe. At the moment, every time we ask for a model by id, we return turn the result of doing Repo.get(id) and this returns either a struct or nil. While this is fine, it is not so easy to pattern match in the caller code.

Describe the solution you'd like Return a tuple {:ok, term()} when the model is found. Return :not_found when no such a row exists in the database.