Data fetching method naming best practices?


Looking for pointers on best practices on how to name business layer specific data access methods.

Ecto brings: get, get_by, all, which can be run by themselves or with a Queryable argument.
I find myself often defining supplementary methods which consistently fetch data, for instance, they search by some attribute, or they preload always some of the associations, or maybe preload filtered associations (like Team with active Member records).

How do you structure this kind of access methods?
I add them to respective schema nodules, and call them City.find_by_bar, or Team.with_active_members, and so on, basically I do not have any significantly better naming scheme to be chosen once and for all.

How do you tackle this problem?

1 Like

Have a look here:

And there are other similar threads in the forum as this is a recurring question.