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

Method remove

couchbase/datastructures.py:484–507  ·  view source on GitHub ↗

Removes a specific key from the map. Args: mapkey (str): The key in the map to remove. Raises: :class:`~couchbase.exceptions.InvalidArgumentException`: If the key is not in the map.

(self, mapkey: str)

Source from the content-addressed store, hash-verified

482 return sd_res.value[0].get('value', None)
483
484 def remove(self, mapkey: str) -> None:
485 """Removes a specific key from the map.
486
487 Args:
488 mapkey (str): The key in the map to remove.
489
490 Raises:
491 :class:`~couchbase.exceptions.InvalidArgumentException`: If the key is not in the map.
492
493 """
494 op_type = DatastructureOperationType.MapRemove
495 with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler:
496 ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict())
497 kv_op_type = KeyValueOperationType.MutateIn
498 with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
499 try:
500 op = remove(mapkey)
501 req = self._impl.request_builder.build_mutate_in_request(self._key,
502 (op,),
503 obs_handler,
504 parent_span=ds_obs_handler.wrapped_span)
505 self._impl.mutate_in(req, obs_handler)
506 except PathNotFoundException:
507 raise InvalidArgumentException(message=f'Key: {mapkey} is not in the map.') from None
508
509 def size(self) -> int:
510 """Returns the number of items in the map.

Callers 4

clearMethod · 0.45
clearMethod · 0.45
clearMethod · 0.45
clearMethod · 0.45

Calls 7

removeFunction · 0.90
get_details_as_dictMethod · 0.80
create_kv_spanMethod · 0.45
mutate_inMethod · 0.45

Tested by

no test coverage detected