Reputation: 180
When handling models with associations, what is the best practice to load associated models: to use Repo.preload explicitly or specifying associations that should be pre-loaded when defining a Query?
Upvotes: 4
Views: 911
Reputation: 51369
They are equivalent so any approach is fine, really. Make it part of the query if you want to have everything in one place. Repo.preload/2
is useful when, for some reason, the query has already been performed.
Upvotes: 5