Add an item to the beginning of a list. .. warning:: This method is deprecated and will be removed in the 4.7.0 version. Use :meth:`.CouchbaseList.prepend` instead. Args: key (str): The key for the list document. value (JSONType): T
(self,
key: str,
value: JSONType,
create: Optional[bool] = False,
**kwargs: object
)
| 1226 | return OperationResult(sd_res.cas, sd_res.mutation_token()) |
| 1227 | |
| 1228 | def list_prepend(self, |
| 1229 | key: str, |
| 1230 | value: JSONType, |
| 1231 | create: Optional[bool] = False, |
| 1232 | **kwargs: object |
| 1233 | ) -> OperationResult: |
| 1234 | """ Add an item to the beginning of a list. |
| 1235 | |
| 1236 | .. warning:: |
| 1237 | This method is deprecated and will be removed in the 4.7.0 version. Use :meth:`.CouchbaseList.prepend` |
| 1238 | instead. |
| 1239 | |
| 1240 | Args: |
| 1241 | key (str): The key for the list document. |
| 1242 | value (JSONType): The value to prepend to the list. |
| 1243 | create (bool, optional): Whether the list should be created if it does not exist. |
| 1244 | **kwargs (Dict[str, Any]): keyword arguments that can be used as optional parameters |
| 1245 | for this operation. |
| 1246 | |
| 1247 | Returns: |
| 1248 | :class:`~couchbase.result.OperationResult`: An instance of :class:`~couchbase.result.OperationResult`. |
| 1249 | |
| 1250 | Raises: |
| 1251 | :class:`~couchbase.exceptions.DocumentNotFoundException`: If the key provided does not exist |
| 1252 | on the server. |
| 1253 | |
| 1254 | """ |
| 1255 | op_type = DatastructureOperationType.ListPrepend |
| 1256 | with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler: |
| 1257 | ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict()) |
| 1258 | kv_op_type = KeyValueOperationType.MutateIn |
| 1259 | with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler: |
| 1260 | op = array_prepend('', value) |
| 1261 | req = self._impl.request_builder.build_mutate_in_request(key, |
| 1262 | (op,), |
| 1263 | obs_handler, |
| 1264 | **kwargs) |
| 1265 | sd_res = self._execute_deprecated_ds_func(self._impl.mutate_in, |
| 1266 | req, |
| 1267 | obs_handler, |
| 1268 | ds_obs_handler.wrapped_span, |
| 1269 | create=create, |
| 1270 | create_type=list, |
| 1271 | path_value=value) |
| 1272 | return OperationResult(sd_res.cas, sd_res.mutation_token()) |
| 1273 | |
| 1274 | def list_set(self, |
| 1275 | key: str, |