Remove the element at a specific index from a list. .. warning:: This method is deprecated and will be removed in the 4.7.0 version. Use :meth:`.CouchbaseList.remove_at` instead. Args: key (str): The key for the list document. index
(self, key: str, index: int, **kwargs: object)
| 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. |
| 1358 | |
| 1359 | .. warning:: |
| 1360 | This method is deprecated and will be removed in the 4.7.0 version. Use :meth:`.CouchbaseList.remove_at` |
| 1361 | instead. |
| 1362 | |
| 1363 | Args: |
| 1364 | key (str): The key for the list document. |
| 1365 | index (int): The position to remove. |
| 1366 | **kwargs (Dict[str, Any]): keyword arguments that can be used as optional parameters |
| 1367 | for this operation. |
| 1368 | |
| 1369 | Returns: |
| 1370 | :class:`~couchbase.result.OperationResult`: An instance of :class:`~couchbase.result.OperationResult`. |
| 1371 | |
| 1372 | Raises: |
| 1373 | :class:`~couchbase.exceptions.DocumentNotFoundException`: If the key provided does not exist |
| 1374 | on the server. |
| 1375 | IndexError: If the index is out of bounds. |
| 1376 | |
| 1377 | """ |
| 1378 | op_type = DatastructureOperationType.ListRemoveAt |
| 1379 | with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 1380 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 1381 | kv_op_type = KeyValueOperationType.MutateIn |
| 1382 | with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 1383 | op = subdoc_remove(f'[{index}]') |
| 1384 | req = self._impl.request_builder.build_mutate_in_request(key, (op,), obs_handler, **kwargs) |
| 1385 | sd_res = self._execute_deprecated_ds_func(self._impl.mutate_in, |
| 1386 | req, |
| 1387 | obs_handler, |
| 1388 | ds_obs_handler.wrapped_span, |
| 1389 | path_value=index) |
| 1390 | return OperationResult(sd_res.cas, sd_res.mutation_token()) |
| 1391 | |
| 1392 | def list_size(self, key: str, **kwargs: object) -> int: |
| 1393 | """Returns the number of items in the list. |