# `TdsCdc.Capture`

Handles querying SQL Server CDC tables and parsing the results.

This module is responsible for:
- Checking if CDC is enabled on the database
- Listing available capture instances
- Fetching changes from CDC tables

# `capture_instance_exists_query`

```elixir
@spec capture_instance_exists_query(String.t()) :: String.t()
```

Returns the SQL query to check if a specific capture instance exists.

# `cdc_enabled_query`

```elixir
@spec cdc_enabled_query() :: String.t()
```

Returns the SQL query to check if CDC is enabled on the current database.

# `fetch_changes`

```elixir
@spec fetch_changes(GenServer.server(), String.t(), binary()) ::
  {:ok, [TdsCdc.Change.t()]} | {:error, term()}
```

Fetches all changes from a capture instance since the given LSN.

This function performs three queries:
1. Get the current max LSN
2. Increment the from_lsn (since CDC functions are inclusive)
3. Query the CDC change table function

Returns `{:ok, changes}` with a list of `%Change{}` structs, or `{:error, reason}`.

# `get_increment_lsn`

```elixir
@spec get_increment_lsn(GenServer.server(), binary()) ::
  {:ok, binary()} | {:error, term()}
```

Gets the next LSN after the given one.

# `get_max_lsn`

```elixir
@spec get_max_lsn(GenServer.server()) :: {:ok, binary()} | {:error, term()}
```

Gets the maximum LSN from the transaction log.

# `get_min_lsn`

```elixir
@spec get_min_lsn(GenServer.server(), String.t()) ::
  {:ok, binary()} | {:error, term()}
```

Gets the minimum LSN for a capture instance, which represents the earliest
available change data.

# `list_capture_instances_query`

```elixir
@spec list_capture_instances_query() :: String.t()
```

Returns the SQL query to list all capture instances in the current database.

---

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