CDT Write Builders¶
- class aerospike_sdk.aio.operations.cdt_write.CdtWriteBuilder[source]¶
Bases:
_RemoveMixin,CdtReadBuilder[T]CDT action builder with read, remove, and write terminals.
Inherits all read terminals and navigation from
CdtReadBuilder. Addsremove(), and on map-key pathsset_to()/add(). Navigation returnsCdtWriteBuilderto preserve write capability.Example
Set a nested map value and remove another key:
await ( session.upsert(key) .bin("settings").on_map_key("theme").set_to("dark") .bin("settings").on_map_key("old_key").remove() .execute() )
- __init__(parent, op_factory, remove_factory, return_type_cls, *, is_map, bin_name='', ctx=(), to_ctx=None, set_to_factory=None, add_factory=None)[source]¶
- on_map_key(key, *, create_type=None)[source]¶
Navigate into a map element by key (supports set_to / add).
- Parameters:
- Return type:
- Returns:
CdtWriteBuilderfor writing the targeted element.
- on_list_index(index, *, order=None, pad=False)[source]¶
Navigate into a list element by index.
- Return type:
- on_map_value(value)[source]¶
Navigate into map elements matching a value (may match multiple).
- Return type:
- on_map_index_range(index, count=None)[source]¶
Navigate into map elements by index range.
- Return type:
- on_map_key_range(start, end)[source]¶
Navigate into map elements by key range
[start, end).- Return type:
- on_map_value_range(start, end)[source]¶
Navigate into map elements by value range
[start, end).- Return type:
- on_map_key_relative_index_range(key, index, count=None)[source]¶
Navigate into map entries by index range relative to an anchor key.
- Return type:
- on_map_value_relative_rank_range(value, rank, count=None)[source]¶
Navigate into map entries by value rank range relative to an anchor.
- Return type:
- on_map_value_list(values)[source]¶
Navigate into map elements matching a list of values.
- Return type:
- on_list_index_range(index, count=None)[source]¶
Navigate into list elements by index range.
- Return type:
- on_list_rank_range(rank, count=None)[source]¶
Navigate into list elements by rank range.
- Return type:
- on_list_value_range(start, end)[source]¶
Navigate into list elements by value range
[start, end).- Return type:
- on_list_value_relative_rank_range(value, rank, count=None)[source]¶
Navigate into list elements by value rank range relative to anchor.
- Return type:
- on_list_value_list(values)[source]¶
Navigate into list elements matching a list of values.
- Return type:
- set_to(value)[source]¶
Set the value at the current CDT path.
Requires prior
on_map_key()navigation.Example:
.bin("m").on_map_key("color").set_to("blue")
- Raises:
TypeError – If not preceded by
on_map_key()navigation.
- map_clear()[source]¶
Remove all entries from the map at the current CDT path.
- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- map_upsert_items(items, *, order=None, persist_index=False, no_fail=False, partial=False)[source]¶
Put multiple map entries (create or update each key).
- Parameters:
- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- map_insert_items(items, *, order=None, persist_index=False, no_fail=False, partial=False)[source]¶
Put map entries only for keys that do not yet exist.
- Parameters:
- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- map_update_items(items, *, order=None, persist_index=False, no_fail=False, partial=False)[source]¶
Update existing map entries only (no new keys).
- Parameters:
- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- map_create(order)[source]¶
Create an empty map with the given key order.
- Parameters:
order (
MapOrder) – Key sort order for the map.- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- map_set_policy(order)[source]¶
Set map sort order policy without changing entries.
- Parameters:
order (
MapOrder) – Key sort order to apply.- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- list_clear()[source]¶
Remove all elements from the list at the current CDT path.
- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- list_sort(flags=ListSortFlags.DEFAULT)[source]¶
Sort the list at the current path.
- Parameters:
flags (
ListSortFlags) – Sort behaviour flags (defaultDEFAULT).- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- list_append_items(items, *, unique=False, bounded=False, no_fail=False, partial=False)[source]¶
Append values to an unordered list.
- Parameters:
- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
Example:
.bin("tags").on_map_key("items").list_append_items([10, 20])
- list_add_items(items, *, unique=False, bounded=False, no_fail=False, partial=False)[source]¶
Insert values into an ordered list (sorted positions).
- Parameters:
- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- list_create(order, *, pad=False, persist_index=False)[source]¶
Create an empty list with the given order.
- list_set_order(order)[source]¶
Set list sort order without changing elements.
- Parameters:
order (
ListOrderType) – Sort order to apply.- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
- list_insert(index, value, *, unique=False, bounded=False, no_fail=False)[source]¶
Insert value at index in the list at the current CDT path.
- Parameters:
- Return type:
TypeVar(T)
- list_insert_items(index, items, *, unique=False, bounded=False, no_fail=False, partial=False)[source]¶
Insert items starting at index in the list at the current path.
- Parameters:
- Return type:
TypeVar(T)
- list_set(index, value)[source]¶
Replace the list element at index with value.
- Return type:
TypeVar(T)
- list_increment(index, value=1)[source]¶
Add value to the numeric element at index (default
1).- Return type:
TypeVar(T)
- list_remove(index)[source]¶
Remove the element at index from the list at the current path.
- Return type:
TypeVar(T)
- list_remove_range(index, count=None)[source]¶
Remove count elements from index, or through the end if count is
None.- Return type:
TypeVar(T)
- list_pop(index)[source]¶
Pop the element at index (returned in the operate result).
- Return type:
TypeVar(T)
- class aerospike_sdk.aio.operations.cdt_write.CdtWriteInvertableBuilder[source]¶
Bases:
CdtWriteBuilder[T],CdtReadInvertableBuilder[T]CDT action builder with read, inverted-read, remove, and nested write paths.
Combines
CdtWriteBuildernavigation (including invertable selectors) with inverted read terminals fromCdtReadInvertableBuilder.Example
Remove everything except the selected range:
.bin("m").on_map_value_range(0, 100).remove_all_others()
- __init__(parent, op_factory, remove_factory, return_type_cls, *, is_map, bin_name='', ctx=(), to_ctx=None)[source]¶
- remove_all_others(*, return_type=None)[source]¶
Remove all CDT elements except the selected ones.
The inverted selection flag is applied automatically; pass only the base return type (for example
MapReturnType.COUNT), not OR’d withINVERTED.Example:
await session.update(key).bin("m").on_map_key_range("b", "d").remove_all_others().execute() stream = await ( session.update(key) .bin("m") .on_map_key_range("b", "d") .remove_all_others(return_type=MapReturnType.VALUE) .execute() )
- Parameters:
return_type (
Any) – What the server should return about the removed elements. When omitted, the server returns no removal metadata (NONE).- Return type:
TypeVar(T)- Returns:
The parent builder for chaining.
See also
remove(): Remove only the current selection.