coryodaniel / arbor

Ecto elixir adjacency list and tree traversal. Supports Ecto versions 2 and 3.
MIT License
239 stars 26 forks source link

Support for preloading associations? #22

Closed MarbilleJuntado closed 5 years ago

MarbilleJuntado commented 5 years ago

I want to be able to do something like: folder |> Folder.descendants(preload: [:contracts]) |> Repo.all

Right now, I'm using the following solution: folder |> Folder.descendants |> Repo.all |> Enum.map(&Repo.preload(&1, [:contracts])) which looks very hack-y.

coryodaniel commented 5 years ago

Do either of these work?

folder |> Folder.descendants() |> Repo.preload([:contracts])

folder |> Folder.descendants() |> Ecto.Query.preload([:contracts])