Get the number of items in the map. :param key: The document ID of the map :return int: The number of items in the map .. seealso:: :meth:`map_add`
(self)
| 526 | raise InvalidArgumentException(message=f'Key: {mapkey} is not in the map.') from None |
| 527 | |
| 528 | async def size(self) -> int: |
| 529 | """ |
| 530 | Get the number of items in the map. |
| 531 | |
| 532 | :param key: The document ID of the map |
| 533 | :return int: The number of items in the map |
| 534 | |
| 535 | .. seealso:: :meth:`map_add` |
| 536 | """ |
| 537 | op_type = DatastructureOperationType.MapSize |
| 538 | async with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 539 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 540 | kv_op_type = KeyValueOperationType.LookupIn |
| 541 | async with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 542 | op = count('') |
| 543 | req, transcoder = self._impl.request_builder.build_lookup_in_request(self._key, |
| 544 | (op,), |
| 545 | obs_handler, |
| 546 | parent_span=ds_obs_handler.wrapped_span) # noqa: E501 |
| 547 | sd_res: LookupInResult = await self._execute_op(self._impl.lookup_in, |
| 548 | req, |
| 549 | obs_handler, |
| 550 | ds_obs_handler.wrapped_span, |
| 551 | create_type=True, |
| 552 | transcoder=transcoder) |
| 553 | return sd_res.value[0].get('value', None) |
| 554 | |
| 555 | async def exists(self, key: str) -> bool: |
| 556 | """ |