View Source EctoHooks.Delta (ecto_hooks v1.2.1)

Defines the struct which is given as the 2nd argument to any after_* hooks.

Contains metadata which may be useful for introspecting or otherwise conditionally running hooks only when certain conditions are met.

The following information is present in an EctoHooks.Delta:

  • The Ecto.Repo callback that triggered the hook
  • The name of the current hook (useful if delegating to private functions in your schema)
  • The Ecto.Queryable passed into the triggering Ecto.Repo callback if any
  • The Ecto.Changeset passed into the triggering Ecto.Repo callback if any

Summary

Types

@type hook() ::
  :before_update
  | :before_insert
  | :before_delete
  | :after_update
  | :after_insert
  | :after_get
  | :after_delete
@type repo_callback() ::
  :update
  | :update!
  | :preload
  | :reload
  | :reload!
  | :one
  | :one!
  | :insert_or_update
  | :insert_or_update!
  | :insert
  | :insert!
  | :get_by
  | :get_by!
  | :get
  | :get!
  | :delete
  | :delete!
  | :all
@type t() :: %EctoHooks.Delta{
  changeset: term(),
  hook: term(),
  queryable: term(),
  record: term(),
  repo_callback: term(),
  source: term()
}

Functions

Link to this function

new!(repo_callback, hook, source)

View Source
@spec new!(repo_callback(), hook(), source :: any()) :: t() | no_return()