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

Method add

couchbase/datastructures.py:432–454  ·  view source on GitHub ↗

Sets a specific key to the specified value in the map. Args: mapkey (str): The key to set. value (JSONType): The value to set.

(self, mapkey: str, value: Any)

Source from the content-addressed store, hash-verified

430 transcoder=transcoder)
431
432 def add(self, mapkey: str, value: Any) -> None:
433 """Sets a specific key to the specified value in the map.
434
435 Args:
436 mapkey (str): The key to set.
437 value (JSONType): The value to set.
438
439 """
440 op_type = DatastructureOperationType.MapAdd
441 with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler:
442 ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict())
443 kv_op_type = KeyValueOperationType.MutateIn
444 with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
445 op = upsert(mapkey, value)
446 req = self._impl.request_builder.build_mutate_in_request(self._key,
447 (op,),
448 obs_handler,
449 parent_span=ds_obs_handler.wrapped_span)
450 return self._execute_op(self._impl.mutate_in,
451 req,
452 obs_handler,
453 ds_obs_handler.wrapped_span,
454 create_type=True)
455
456 def get(self, mapkey: str) -> Any:
457 """Fetches a specific key from the map.

Callers 15

add_mutation_tokenMethod · 0.45
_add_scanvecMethod · 0.45
test_mapMethod · 0.45
test_setsMethod · 0.45
test_kv_ds_mapMethod · 0.45
test_kv_ds_setMethod · 0.45
test_kv_ds_mapMethod · 0.45
test_kv_ds_setMethod · 0.45
get_new_doc_by_typeMethod · 0.45

Calls 6

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

Tested by 8

test_mapMethod · 0.36
test_setsMethod · 0.36
test_kv_ds_mapMethod · 0.36
test_kv_ds_setMethod · 0.36
test_kv_ds_mapMethod · 0.36
test_kv_ds_setMethod · 0.36
get_existing_docMethod · 0.36
get_new_docMethod · 0.36