# `Bylaw.Db.Target`
[🔗](https://github.com/ryanzidago/bylaw/blob/v0.1.0-alpha.1/lib/bylaw/db/target.ex#L1)

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}

# `query_fun`

```elixir
@type query_fun() :: (t(), sql :: String.t(), params :: [term()], opts :: keyword() -&gt;
                  {:ok, term()} | {:error, term()})
```

Optional query function for custom target wiring.

# `t`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
