MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / exists

Method exists

acouchbase/datastructures.py:555–580  ·  view source on GitHub ↗

Checks whether a specific key exists in the map. :param key: The key to check :return bool: If the key exists in the map or not .. seealso:: :meth:`map_add`

(self, key: str)

Source from the content-addressed store, hash-verified

553 return sd_res.value[0].get('value', None)
554
555 async def exists(self, key: str) -> bool:
556 """
557 Checks whether a specific key exists in the map.
558
559 :param key: The key to check
560 :return bool: If the key exists in the map or not
561
562 .. seealso:: :meth:`map_add`
563 """
564 op_type = DatastructureOperationType.MapExists
565 async with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler:
566 ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict())
567 kv_op_type = KeyValueOperationType.LookupIn
568 async with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
569 op = subdoc_exists(key)
570 req, transcoder = self._impl.request_builder.build_lookup_in_request(self._key,
571 (op,),
572 obs_handler,
573 parent_span=ds_obs_handler.wrapped_span) # noqa: E501
574 sd_res: LookupInResult = await self._execute_op(self._impl.lookup_in,
575 req,
576 obs_handler,
577 ds_obs_handler.wrapped_span,
578 create_type=True,
579 transcoder=transcoder)
580 return sd_res.exists(0)
581
582 async def keys(self) -> List[str]:
583 """

Callers

nothing calls this directly

Calls 5

_execute_opMethod · 0.95
get_details_as_dictMethod · 0.80
create_kv_spanMethod · 0.45

Tested by

no test coverage detected