It's clear how to preload associations in Ecto 1-2 levels deep, such as post and comments to it.
I have an Address
, and Address
belongs_to a Street
, and Street
belongs_to a City
, and City
belongs_to Region, and Region
belong_to a Country
Given Address
:
addr = Repo.get(Address, 123)
|> Repo.preload(street: ?????)
how do I preload it all the way to Country
:
IO.puts("the name of country: #{addr.street.city.region.country.name}")
?
preload(street: [city: [], base: [] ], boulevard: [])
– Kermie