# `Aerospike.BatchResult`
[🔗](https://github.com/luisgabrielroldan/aerospike_driver/blob/v0.3.1/lib/aerospike/batch_result.ex#L1)

Per-key outcome returned by batch helpers that need record-level metadata.

Each result keeps the original key and a status so callers can handle partial
batch outcomes without losing caller-order context.

## Field invariants

- When `status` is `:ok`, `error` is `nil`. `record` may contain returned
  data or be `nil` for successful operations that do not return bins.
- When `status` is `:error`, `record` is `nil`, `error` is set, and
  `in_doubt` reports whether a write outcome may be ambiguous.

# `error_reason`

```elixir
@type error_reason() :: Aerospike.Error.t() | atom()
```

Per-key batch error returned for failed entries.

Command paths normally return `%Aerospike.Error{}`; atom reasons are kept in
the type because lower-level routing failures can surface before an error
struct is available.

# `status`

```elixir
@type status() :: :ok | :error
```

Per-key batch status, preserving caller order across partial outcomes.

# `t`

```elixir
@type t() :: %Aerospike.BatchResult{
  error: error_reason() | nil,
  in_doubt: boolean(),
  key: Aerospike.Key.t(),
  record: Aerospike.Record.t() | map() | nil,
  status: status()
}
```

Per-key result returned by heterogeneous batch helpers.

`record` contains returned bins or metadata for successful entries that
produce data. `error` is set only when `status` is `:error`. `in_doubt`
indicates that a write-style entry may have reached the server even though
the client received an error.

# `from_command_result`

```elixir
@spec from_command_result(term()) :: t()
```

Converts one command-layer batch result into a public batch result struct.

# `from_command_results`

```elixir
@spec from_command_results([term()]) :: [t()]
```

Converts command-layer batch results into public batch result structs.

The returned list preserves the command result order, which matches the
caller's key or entry order for public batch helpers.

---

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