Get a specific element within a list. .. warning:: This method is deprecated and will be removed in the 4.7.0 version. Use :meth:`.CouchbaseList.get_at` instead. Args: key (str): The key for the list document. index (int): The positi
(self, key: str, index: int, **kwargs: object)
| 1317 | return OperationResult(sd_res.cas, sd_res.mutation_token()) |
| 1318 | |
| 1319 | def list_get(self, key: str, index: int, **kwargs: object) -> Any: |
| 1320 | """Get a specific element within a list. |
| 1321 | |
| 1322 | .. warning:: |
| 1323 | This method is deprecated and will be removed in the 4.7.0 version. Use :meth:`.CouchbaseList.get_at` |
| 1324 | instead. |
| 1325 | |
| 1326 | Args: |
| 1327 | key (str): The key for the list document. |
| 1328 | index (int): The position to retrieve. |
| 1329 | **kwargs (Dict[str, Any]): keyword arguments that can be used as optional parameters |
| 1330 | for this operation. |
| 1331 | |
| 1332 | Returns: |
| 1333 | Any: The value of the element at the specified index. |
| 1334 | |
| 1335 | Raises: |
| 1336 | :class:`~couchbase.exceptions.DocumentNotFoundException`: If the key provided does not exist |
| 1337 | on the server. |
| 1338 | IndexError: If the index is out of bounds. |
| 1339 | |
| 1340 | """ |
| 1341 | op_type = DatastructureOperationType.ListGetAt |
| 1342 | with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 1343 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 1344 | kv_op_type = KeyValueOperationType.LookupIn |
| 1345 | with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 1346 | op = subdoc_get(f'[{index}]') |
| 1347 | req, transcoder = self._impl.request_builder.build_lookup_in_request(key, (op,), obs_handler, **kwargs) |
| 1348 | sd_res = self._execute_deprecated_ds_func(self._impl.lookup_in, |
| 1349 | req, |
| 1350 | obs_handler, |
| 1351 | ds_obs_handler.wrapped_span, |
| 1352 | path_value=index, |
| 1353 | transcoder=transcoder) |
| 1354 | return sd_res.value[0].get('value', None) |
| 1355 | |
| 1356 | def list_remove(self, key: str, index: int, **kwargs: object) -> OperationResult: |
| 1357 | """Remove the element at a specific index from a list. |