MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / add

Method add

acouchbase/datastructures.py:714–739  ·  view source on GitHub ↗

Add an item to a set if the item does not yet exist. :param value: Value to add .. seealso:: :meth:`map_add`

(self, value: Any)

Source from the content-addressed store, hash-verified

712 transcoder=transcoder)
713
714 async def add(self, value: Any) -> bool:
715 """
716 Add an item to a set if the item does not yet exist.
717
718 :param value: Value to add
719 .. seealso:: :meth:`map_add`
720 """
721 op_type = DatastructureOperationType.SetAdd
722 async with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler:
723 ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict())
724 kv_op_type = KeyValueOperationType.MutateIn
725 async with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
726 try:
727 op = array_addunique('', value)
728 req = self._impl.request_builder.build_mutate_in_request(self._key,
729 (op,),
730 obs_handler,
731 parent_span=ds_obs_handler.wrapped_span)
732 await self._execute_op(self._impl.mutate_in,
733 req,
734 obs_handler,
735 ds_obs_handler.wrapped_span,
736 create_type=True)
737 return True
738 except PathExistsException:
739 return False
740
741 async def remove(self, value: Any, timeout: Optional[timedelta] = None) -> None: # noqa: C901
742 """

Callers

nothing calls this directly

Calls 6

_execute_opMethod · 0.95
array_adduniqueFunction · 0.90
get_details_as_dictMethod · 0.80
create_kv_spanMethod · 0.45

Tested by

no test coverage detected