# `Aerospike.Op.List`
[🔗](https://github.com/luisgabrielroldan/aerospike_driver/blob/v0.3.1/lib/aerospike/op/list.ex#L1)

List CDT operations for `Aerospike.operate/4`.

These builders create server-side list operations. Pass `ctx:` for nested CDT
paths and `return_type:` for selector operations that can return indexes,
ranks, counts, values, or existence flags.

# `opts`

```elixir
@type opts() :: [
  ctx: Aerospike.Ctx.t(),
  return_type: return_type(),
  policy: policy(),
  persist_index: boolean(),
  pad: boolean()
]
```

Common list operation options.

Supported keys:

* `:ctx` - nested CDT context path from `Aerospike.Ctx`.
* `:return_type` - selector return type such as `:value`, `:count`, or
  `[:value, :inverted]`.
* `:policy` - list write policy map for write operations that document it.
* `:persist_index` - persist the index for top-level ordered lists.
* `:pad` - allow nested list creation past the current boundary.

# `order`

```elixir
@type order() :: :unordered | :ordered | raw_integer()
```

List order attribute.

# `policy`

```elixir
@type policy() ::
  %{optional(:order) =&gt; order(), optional(:flags) =&gt; write_flags()}
  | [order: order(), flags: write_flags()]
```

List write policy accepted in `opts[:policy]`.

Append, insert, and set operations expect both `:order` and `:flags`;
increment only reads `:flags`.

# `raw_integer`

```elixir
@type raw_integer() :: non_neg_integer() | {:raw, non_neg_integer()}
```

Raw compatibility value for server integer policy constants.

# `return_type`

```elixir
@type return_type() ::
  :none
  | :index
  | :reverse_index
  | :rank
  | :reverse_rank
  | :count
  | :value
  | :exists
  | :inverted
  | [
      :inverted
      | :index
      | :reverse_index
      | :rank
      | :reverse_rank
      | :count
      | :value
      | :exists
    ]
  | raw_integer()
```

List selector return type.

# `sort_flags`

```elixir
@type sort_flags() ::
  :default
  | :descending
  | :drop_duplicates
  | [:descending | :drop_duplicates]
  | raw_integer()
```

List sort flag or flags.

# `t`

```elixir
@opaque t()
```

Opaque list CDT operation for `Aerospike.operate/4`.

# `write_flag`

```elixir
@type write_flag() :: :default | :add_unique | :insert_bounded | :no_fail | :partial
```

List write policy flag or flags.

# `write_flags`

```elixir
@type write_flags() :: write_flag() | [write_flag()] | raw_integer()
```

# `append`

```elixir
@spec append(String.t(), term(), opts()) :: t()
```

Appends a value to a list bin.

Pass `policy: [order: order, flags: flags]` to include list order and write
flags in the operation payload.

# `append_items`

```elixir
@spec append_items(String.t(), list(), opts()) :: t()
```

Appends multiple values to a list bin.

Pass `policy: [order: order, flags: flags]` to include list order and write
flags in the operation payload.

# `clear`

```elixir
@spec clear(String.t(), opts()) :: t()
```

Removes all values from the list.

# `create`

```elixir
@spec create(String.t(), order(), opts()) :: t()
```

Creates a list at the selected context level.

When `ctx:` is omitted, this sets the top-level bin list order. For nested
lists, pass `pad: true` to allow create indexes beyond the current boundary.

# `get`

```elixir
@spec get(String.t(), integer(), opts()) :: t()
```

Returns the value at `index`.

# `get_by_index`

```elixir
@spec get_by_index(String.t(), integer(), opts()) :: t()
```

Returns the value at `index`, selected by `return_type:`.

# `get_by_index_range`

```elixir
@spec get_by_index_range(String.t(), integer(), integer(), opts()) :: t()
```

Returns `count` values from `index`, selected by `return_type:`.

# `get_by_index_range_from`

```elixir
@spec get_by_index_range_from(String.t(), integer(), opts()) :: t()
```

Returns values from `index` through the end, selected by `return_type:`.

# `get_by_rank`

```elixir
@spec get_by_rank(String.t(), integer(), opts()) :: t()
```

Returns the value at `rank`, selected by `return_type:`.

# `get_by_rank_range`

```elixir
@spec get_by_rank_range(String.t(), integer(), integer(), opts()) :: t()
```

Returns `count` values from `rank`, selected by `return_type:`.

# `get_by_rank_range_from`

```elixir
@spec get_by_rank_range_from(String.t(), integer(), opts()) :: t()
```

Returns values from `rank` through the highest rank, selected by `return_type:`.

# `get_by_value`

```elixir
@spec get_by_value(String.t(), term(), opts()) :: t()
```

Returns values equal to `value`, selected by `return_type:`.

# `get_by_value_list`

```elixir
@spec get_by_value_list(String.t(), list(), opts()) :: t()
```

Returns values matching any entry in `values`, selected by `return_type:`.

# `get_by_value_range`

```elixir
@spec get_by_value_range(String.t(), term(), term(), opts()) :: t()
```

Returns values in `[begin_value, end_value)`, selected by `return_type:`.

Pass `nil` for an open range boundary.

# `get_by_value_rel_rank_range`

```elixir
@spec get_by_value_rel_rank_range(String.t(), term(), integer(), opts()) :: t()
```

Returns values nearest to `value` and greater by relative `rank`.

# `get_by_value_rel_rank_range_count`

```elixir
@spec get_by_value_rel_rank_range_count(
  String.t(),
  term(),
  integer(),
  integer(),
  opts()
) :: t()
```

Returns `count` values nearest to `value` and greater by relative `rank`.

# `get_range`

```elixir
@spec get_range(String.t(), integer(), integer(), opts()) :: t()
```

Returns `count` values starting at `index`.

# `get_range_from`

```elixir
@spec get_range_from(String.t(), integer(), opts()) :: t()
```

Returns values from `index` through the end of the list.

# `increment`

```elixir
@spec increment(String.t(), integer(), term(), opts()) :: t()
```

Increments the numeric value at `index`.

Pass `policy: %{flags: flags}` to include write flags in the operation
payload.

# `insert`

```elixir
@spec insert(String.t(), integer(), term(), opts()) :: t()
```

Inserts a value at `index`.

# `insert_items`

```elixir
@spec insert_items(String.t(), integer(), list(), opts()) :: t()
```

Inserts multiple values at `index`.

# `order_ordered`

```elixir
@spec order_ordered() :: 1
```

Create ordered lists.

# `order_unordered`

```elixir
@spec order_unordered() :: 0
```

Create unordered lists by default.

# `pop`

```elixir
@spec pop(String.t(), integer(), opts()) :: t()
```

Removes and returns the value at `index`.

# `pop_range`

```elixir
@spec pop_range(String.t(), integer(), integer(), opts()) :: t()
```

Removes and returns `count` values starting at `index`.

# `pop_range_from`

```elixir
@spec pop_range_from(String.t(), integer(), opts()) :: t()
```

Removes and returns values from `index` through the end of the list.

# `remove`

```elixir
@spec remove(String.t(), integer(), opts()) :: t()
```

Removes the value at `index` and returns the removed count.

# `remove_by_index`

```elixir
@spec remove_by_index(String.t(), integer(), opts()) :: t()
```

Removes the value at `index`, returning data selected by `return_type:`.

# `remove_by_index_range`

```elixir
@spec remove_by_index_range(String.t(), integer(), integer(), opts()) :: t()
```

Removes `count` values from `index`, returning selected data.

# `remove_by_index_range_from`

```elixir
@spec remove_by_index_range_from(String.t(), integer(), opts()) :: t()
```

Removes values from `index` through the end, returning selected data.

# `remove_by_rank`

```elixir
@spec remove_by_rank(String.t(), integer(), opts()) :: t()
```

Removes the value at `rank`, returning data selected by `return_type:`.

# `remove_by_rank_range`

```elixir
@spec remove_by_rank_range(String.t(), integer(), integer(), opts()) :: t()
```

Removes `count` values from `rank`, returning selected data.

# `remove_by_rank_range_from`

```elixir
@spec remove_by_rank_range_from(String.t(), integer(), opts()) :: t()
```

Removes values from `rank` through the highest rank, returning selected data.

# `remove_by_value`

```elixir
@spec remove_by_value(String.t(), term(), opts()) :: t()
```

Removes values equal to `value`, returning data selected by `return_type:`.

# `remove_by_value_list`

```elixir
@spec remove_by_value_list(String.t(), list(), opts()) :: t()
```

Removes values matching any entry in `values`, returning selected data.

# `remove_by_value_range`

```elixir
@spec remove_by_value_range(String.t(), term(), term(), opts()) :: t()
```

Removes values in `[begin_value, end_value)`, returning selected data.

Pass `nil` for an open range boundary.

# `remove_by_value_rel_rank_range`

```elixir
@spec remove_by_value_rel_rank_range(String.t(), term(), integer(), opts()) :: t()
```

Removes values nearest to `value` and greater by relative `rank`.

# `remove_by_value_rel_rank_range_count`

```elixir
@spec remove_by_value_rel_rank_range_count(
  String.t(),
  term(),
  integer(),
  integer(),
  opts()
) :: t()
```

Removes `count` values nearest to `value` and greater by relative `rank`.

# `remove_range`

```elixir
@spec remove_range(String.t(), integer(), integer(), opts()) :: t()
```

Removes `count` values starting at `index` and returns the removed count.

# `remove_range_from`

```elixir
@spec remove_range_from(String.t(), integer(), opts()) :: t()
```

Removes values from `index` through the end and returns the removed count.

# `return_count`

```elixir
@spec return_count() :: 5
```

Return the selected item count.

# `return_exists`

```elixir
@spec return_exists() :: 13
```

Return whether matching items exist.

# `return_index`

```elixir
@spec return_index() :: 1
```

Return selected item indexes.

# `return_inverted`

```elixir
@spec return_inverted() :: 65536
```

Invert the selector so it applies outside the matched range.

# `return_none`

```elixir
@spec return_none() :: 0
```

Return no result for a selector operation.

# `return_rank`

```elixir
@spec return_rank() :: 3
```

Return selected value ranks.

# `return_reverse_index`

```elixir
@spec return_reverse_index() :: 2
```

Return selected reverse indexes, counted from the list end.

# `return_reverse_rank`

```elixir
@spec return_reverse_rank() :: 4
```

Return selected reverse ranks, counted from the highest value.

# `return_value`

```elixir
@spec return_value() :: 7
```

Return selected value or values.

# `set`

```elixir
@spec set(String.t(), integer(), term(), opts()) :: t()
```

Sets the value at `index`.

Pass `policy: [order: order, flags: flags]` to include list order and write
flags in the operation payload.

# `set_order`

```elixir
@spec set_order(String.t(), order(), opts()) :: t()
```

Sets the list order.

Pass `persist_index: true` to persist an index for a top-level ordered list.

# `set_type`

```elixir
@spec set_type(String.t(), order(), write_flags(), opts()) :: t()
```

Sets the list order and write flags for a list bin.

# `size`

```elixir
@spec size(String.t(), opts()) :: t()
```

Returns the number of values in the list.

# `sort`

```elixir
@spec sort(String.t(), sort_flags() | opts(), opts()) :: t()
```

Sorts the list with `sort_flags`.

# `trim`

```elixir
@spec trim(String.t(), integer(), integer(), opts()) :: t()
```

Keeps `count` values starting at `index` and removes all others.

# `write_add_unique`

```elixir
@spec write_add_unique() :: 1
```

Only add unique list values.

# `write_default`

```elixir
@spec write_default() :: 0
```

Use default list write behavior.

# `write_insert_bounded`

```elixir
@spec write_insert_bounded() :: 2
```

Require list insert indexes to be inside list boundaries.

# `write_no_fail`

```elixir
@spec write_no_fail() :: 4
```

Do not fail the command when a list item is rejected by write flags.

# `write_partial`

```elixir
@spec write_partial() :: 8
```

Commit valid list items even when another item is rejected by write flags.

---

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