Skip to content

A module to dynamically preload based on schema files.

Notifications You must be signed in to change notification settings

DefactoSoftware/Preload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Preload

Installation

def deps do
  [
    {:preload, "~> 0.1.0"}
  ]
end

Usage

To use Preload scopes add a file named <Your.Schema> where Your.Schema should be the module of the schema you're trying to preload on. Next to that add a file with the module <Your.Schema>.Scopes in this module you can add scope_on_preload/4 functions.

Example:

defmodule App.Jobs.Enrollment do
  def some_fun(actor, %{preload: preload)) do
    Job
    |> where(active: true)
    |> Preload.scope(preload, actor)
  end
end

defmodule App.Jobs.Enrollment.Scopes do
  def scope_on_preload(query, preloads, user, options) do
    #...
  end
end

About

A module to dynamically preload based on schema files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages