Aerospike.Op (Aerospike Driver v0.3.1)

Copy Markdown View Source

Primitive record operations for Aerospike.operate/4.

These builders create the simple bin operations used by the server's operate command: write a bin, read a bin, read only record metadata, increment a numeric bin, and append or prepend string data. Use the CDT modules for collection bins and Aerospike.Op.Exp for expression-backed operate calls.

key = Aerospike.key("test", "users", "user:1")

{:ok, record} =
  Aerospike.operate(cluster, key, [
    Aerospike.Op.add("login_count", 1),
    Aerospike.Op.put("last_seen", "2026-04-27"),
    Aerospike.Op.get("login_count")
  ])

Read operations return data in the %Aerospike.Record{} returned by Aerospike.operate/4; write operations affect the record on the server and only return data when the server operation itself produces a result.

See also Aerospike.Op.Bit, Aerospike.Op.Exp, Aerospike.Op.HLL, Aerospike.Op.List, and Aerospike.Op.Map for collection and expression operations.

Summary

Types

Bin name accepted by primitive operate builders.

t()

Opaque wire operation.

Functions

Adds delta to a numeric bin.

Appends suffix to a string bin.

Reads bin_name from the record.

Reads only record metadata.

Prepends prefix to a string bin.

Writes value to bin_name.

Types

bin_name()

@type bin_name() :: String.t() | atom()

Bin name accepted by primitive operate builders.

Atom bin names are converted to strings before the operation is encoded.

t()

@opaque t()

Opaque wire operation.

Functions

add(bin_name, delta)

@spec add(bin_name(), integer() | float()) :: t()

Adds delta to a numeric bin.

The server creates the bin when needed and returns an error if the existing value is not numeric.

append(bin_name, suffix)

@spec append(bin_name(), String.t()) :: t()

Appends suffix to a string bin.

get(bin_name)

@spec get(bin_name()) :: t()

Reads bin_name from the record.

The returned operation projects the requested bin into the operate response.

get_header()

@spec get_header() :: t()

Reads only record metadata.

This operation asks the server for the record generation and TTL without returning bin data.

prepend(bin_name, prefix)

@spec prepend(bin_name(), String.t()) :: t()

Prepends prefix to a string bin.

put(bin_name, value)

@spec put(bin_name(), term()) :: t()

Writes value to bin_name.

The value must be encodable by the Aerospike particle encoder. Atom bin names are converted to strings.