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)
| 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. |
no test coverage detected