Set a value for a key in a map. These functions are all wrappers around the :meth:`mutate_in` or :meth:`lookup_in` methods. :param mapkey: The key in the map to set :param value: The value to use (anything serializable to JSON) .. Initialize a map
(self, mapkey: str, value: Any)
| 433 | transcoder=transcoder) |
| 434 | |
| 435 | async def add(self, mapkey: str, value: Any) -> None: |
| 436 | """ |
| 437 | Set a value for a key in a map. |
| 438 | |
| 439 | These functions are all wrappers around the :meth:`mutate_in` or |
| 440 | :meth:`lookup_in` methods. |
| 441 | |
| 442 | :param mapkey: The key in the map to set |
| 443 | :param value: The value to use (anything serializable to JSON) |
| 444 | |
| 445 | .. Initialize a map and add a value |
| 446 | |
| 447 | cb.upsert('a_map', {}) |
| 448 | cb.map_add('a_map', 'some_key', 'some_value') |
| 449 | cb.map_get('a_map', 'some_key').value # => 'some_value' |
| 450 | cb.get('a_map').value # => {'some_key': 'some_value'} |
| 451 | |
| 452 | """ |
| 453 | op_type = DatastructureOperationType.MapAdd |
| 454 | async with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 455 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 456 | kv_op_type = KeyValueOperationType.MutateIn |
| 457 | async with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 458 | op = upsert(mapkey, value) |
| 459 | req = self._impl.request_builder.build_mutate_in_request(self._key, |
| 460 | (op,), |
| 461 | obs_handler, |
| 462 | parent_span=ds_obs_handler.wrapped_span) |
| 463 | return await self._execute_op(self._impl.mutate_in, |
| 464 | req, |
| 465 | obs_handler, |
| 466 | ds_obs_handler.wrapped_span, |
| 467 | create_type=True) |
| 468 | |
| 469 | async def get(self, mapkey: str) -> Any: |
| 470 | """ |