MCPcopy Index your code
hub / github.com/couchbase/couchbase-python-client / prepend

Method prepend

acouchbase/datastructures.py:160–186  ·  view source on GitHub ↗

Add an item to the beginning of a list. :param value: Value to prepend :return: :class:`OperationResult`. This function is identical to :meth:`list_append`, except for prepending rather than appending the item .. seealso:: :meth:`list_append`, :met

(self, value: JSONType)

Source from the content-addressed store, hash-verified

158 create_type=True)
159
160 async def prepend(self, value: JSONType) -> None:
161 """
162 Add an item to the beginning of a list.
163
164 :param value: Value to prepend
165 :return: :class:`OperationResult`.
166
167 This function is identical to :meth:`list_append`, except for prepending
168 rather than appending the item
169
170 .. seealso:: :meth:`list_append`, :meth:`map_add`
171 """
172 op_type = DatastructureOperationType.ListPrepend
173 async with ObservableRequestHandler(op_type, self._impl.observability_instruments) as ds_obs_handler:
174 ds_obs_handler.create_kv_span(self._impl._request_builder._collection_dtls.get_details_as_dict())
175 kv_op_type = KeyValueOperationType.MutateIn
176 async with ObservableRequestHandler(kv_op_type, self._impl.observability_instruments) as obs_handler:
177 op = array_prepend('', value)
178 req = self._impl.request_builder.build_mutate_in_request(self._key,
179 (op,),
180 obs_handler,
181 parent_span=ds_obs_handler.wrapped_span)
182 await self._execute_op(self._impl.mutate_in,
183 req,
184 obs_handler,
185 ds_obs_handler.wrapped_span,
186 create_type=True)
187
188 async def set_at(self, index: int, value: JSONType) -> None:
189 """

Callers

nothing calls this directly

Calls 6

_execute_opMethod · 0.95
array_prependFunction · 0.90
get_details_as_dictMethod · 0.80
create_kv_spanMethod · 0.45

Tested by

no test coverage detected