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

Link to this function

maybe_preload(obj, preloads, opts \\ [])

View Source

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 Source

Conditionally preloads associations for nested schemas.

Examples

iex> maybe_preloads_per_nested_schema(objects, path, preloads)
[%{...}, %{...}]
Link to this function

maybe_preloads_per_schema(object, schema_preloads, opts \\ [])

View Source

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]})
Link to this function

preload_all(structure, opts \\ [])

View Source

Preloads all associations for a given Ecto struct.

Examples

iex> preload_all(some_struct)
Link to this function

preload_mixins(structure, opts \\ [])

View Source

Preloads mixin associations for a given Ecto struct.

Examples

iex> preload_mixins(some_struct)
Link to this function

schema_mixins(structure)

View Source

Retrieves schema mixins for a given Ecto struct.

Examples

iex> schema_mixins(some_struct)
[:assoc1, :assoc2]