View Source Bonfire.Common.Repo.Preload (Bonfire v0.9.10-classic-beta.169)
Helpers for preloading Ecto struct associations
Summary
Functions
Conditionally preloads associations based on provided options.
Conditionally preloads associations for nested schemas.
Conditionally preloads associations for a schema.
Preloads all associations for a given Ecto struct.
Preloads mixin associations for a given Ecto struct.
Retrieves schema mixins for a given Ecto struct.
Functions
Conditionally preloads associations based on provided options.
Examples
iex> maybe_preload(some_struct, [:assoc1, :assoc2])
%{...}
iex> maybe_preload({:ok, some_struct}, [:assoc1, :assoc2])
{:ok, %{...}}
Link to this function
maybe_preloads_per_nested_schema(objects, path, preloads, opts \\ [])
View SourceConditionally preloads associations for nested schemas.
Examples
iex> maybe_preloads_per_nested_schema(objects, path, preloads)
[%{...}, %{...}]
Conditionally preloads associations for a schema.
Examples
iex> maybe_preloads_per_schema(some_struct, {Schema, [:assoc1, :assoc2]})
iex> maybe_preloads_per_schema(pointer_struct, {PointerSchema, [:assoc1, :assoc2]})
Preloads all associations for a given Ecto struct.
Examples
iex> preload_all(some_struct)
Preloads mixin associations for a given Ecto struct.
Examples
iex> preload_mixins(some_struct)
Retrieves schema mixins for a given Ecto struct.
Examples
iex> schema_mixins(some_struct)
[:assoc1, :assoc2]