Bylaw.Db.Target (bylaw_db v0.1.0-alpha.1)

Copy Markdown View Source

Target validated by database checks.

A target represents one adapter/database query source. Adapter packages build targets from their own options, and checks receive targets from Bylaw.Db.

Examples

iex> target = %Bylaw.Db.Target{adapter: MyApp.DbAdapter, meta: %{database: :primary}}
iex> target.adapter
MyApp.DbAdapter
iex> target.meta
%{database: :primary}

Summary

Types

Optional query function for custom target wiring.

t()

A database validation target.

Types

query_fun()

@type query_fun() :: (t(), sql :: String.t(), params :: [term()], opts :: keyword() ->
                  {:ok, term()} | {:error, term()})

Optional query function for custom target wiring.

t()

@type t() :: %Bylaw.Db.Target{
  adapter: module(),
  dynamic_repo: atom() | pid() | nil,
  meta: map(),
  query: query_fun() | nil,
  repo: module() | nil
}

A database validation target.

adapter is the adapter module that owns query execution. repo, dynamic_repo, query, and meta are adapter-defined fields used by adapter packages and custom checks.