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

Behaviour implemented by database adapter packages.

Adapters build validation targets, run checks, and execute database-specific
introspection queries for checks.

# `query_opt`

```elixir
@type query_opt() :: {atom(), term()}
```

Adapter-specific query execution option.

# `query_opts`

```elixir
@type query_opts() :: [query_opt()]
```

Adapter-specific query execution options.

# `query_result`

```elixir
@type query_result() :: term()
```

Raw database query result returned by an adapter.

# `target_opt`

```elixir
@type target_opt() :: {atom(), term()}
```

Adapter-specific target construction option.

# `target_opts`

```elixir
@type target_opts() :: [target_opt()]
```

Adapter-specific target construction options.

# `query`

```elixir
@callback query(
  target :: Bylaw.Db.Target.t(),
  sql :: String.t(),
  params :: [term()],
  opts :: query_opts()
) :: {:ok, query_result()} | {:error, term()}
```

Executes database-specific introspection SQL for `target`.

Checks call this callback through the target's adapter when they need database
metadata.

# `target`

```elixir
@callback target(opts :: target_opts()) :: Bylaw.Db.Target.t()
```

Builds a single validation target from adapter-specific options.

# `validate`

```elixir
@callback validate(targets :: [Bylaw.Db.Target.t()], checks :: [Bylaw.Db.check_spec()]) ::
  Bylaw.Db.Check.result()
```

Runs `checks` against a non-empty list of targets.

Adapter implementations should usually delegate to `Bylaw.Db.validate/2`.

---

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