RecordResult

class aerospike_sdk.record_result.RecordResult[source]

Bases: object

One row from a batch, query stream, or single-key SDK call.

Inspect is_ok and result_code for outcome; use or_raise() or record_or_raise() when failures should throw. Foreground UDF success values appear in udf_result when returned by the server.

key

Target Key for this row.

record

Record payload, or None if not returned (errors, not found, or UDF error rows).

result_code

Server ResultCode.

in_doubt

True when a write may have completed despite an error.

index

Batch position, or 0 / -1 depending on origin.

exception

Embedded AerospikeError when the client placed an error in-stream instead of raising.

udf_result

Lua return value for successful foreground UDF calls.

Example

Inspect a row from a stream:

row = await stream.first()
if row and row.is_ok:
    bins = row.record.bins if row.record else {}
elif row:
    row.or_raise()

See also

RecordStream: Async iteration of results.

key: Key
record: Record | None
result_code: ResultCode
in_doubt: bool
index: int
exception: AerospikeError | None
udf_result: Any | None
property is_ok: bool

Whether result_code is ResultCode.OK.

Returns:

True on success; False for any other result code.

Example:

row = await stream.first()
if row is not None and row.is_ok and row.record:
    bins = row.record.bins
or_raise()[source]

Return self if successful, else raise from exception or result code.

Return type:

RecordResult

Returns:

This instance when is_ok is true.

Raises:

Example:

row = await stream.first()
if row is not None:
    row.or_raise()
record_or_raise()[source]

Return record, raising if the result is not OK.

Return type:

Record

Returns:

The non-None Record.

:raises Same as or_raise`(), plus ``ValueError` if the result is OK: :raises but record is None (unexpected empty payload).:

Example

rec = (await stream.first_or_raise()).record_or_raise()

as_bool()[source]

Interpret the row as an existence check (for example after Session.exists()).

Return type:

bool

Returns:

True if the key exists (OK result). False if the result is key-not-found.

Raises:

AerospikeError – For any other non-OK code (via or_raise()).

Example

found = (await exists_stream.first_or_raise()).as_bool()

__init__(key, record, result_code, in_doubt=False, index=-1, exception=None, udf_result=None)