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

Function array_prepend

couchbase/subdocument.py:512–536  ·  view source on GitHub ↗

Creates a :class:`.Spec` for adding a value to the beginning of an array in a document. Args: path (str): The path to an element of an array. *values (Iterable[Any]): The values to add. create_parents (bool, optional): Whether or not the path to the field should be creat

(path,              # type: str
                  *values,                 # type: Iterable[Any]
                  create_parents=False,     # type: Optional[bool]
                  xattr=False               # type: Optional[bool]
                  )

Source from the content-addressed store, hash-verified

510
511
512def array_prepend(path, # type: str
513 *values, # type: Iterable[Any]
514 create_parents=False, # type: Optional[bool]
515 xattr=False # type: Optional[bool]
516 ) -> Spec:
517 """Creates a :class:`.Spec` for adding a value to the beginning of an array in a document.
518
519 Args:
520 path (str): The path to an element of an array.
521 *values (Iterable[Any]): The values to add.
522 create_parents (bool, optional): Whether or not the path to the field should be created
523 if it does not already exist.
524 xattr (bool, optional): Whether this operation should reference the document body or the
525 extended attributes data for the document.
526
527 Returns:
528 :class:`.Spec`: An instance of :class:`.Spec`.
529
530 """
531 expand_macros = False
532 if any(map(lambda m: isinstance(m, MutationMacro), values)):
533 values = [v.value if isinstance(v, MutationMacro) else v for v in values]
534 xattr = True
535 expand_macros = True
536 return Spec(SubDocOp.ARRAY_PUSH_FIRST, path, create_parents, xattr, expand_macros, ArrayValues(*values))
537
538
539def array_insert(path, # type: str

Callers 5

prependMethod · 0.90
pushMethod · 0.90
list_prependMethod · 0.90
prependMethod · 0.90
pushMethod · 0.90

Calls 2

SpecClass · 0.85
ArrayValuesClass · 0.85

Tested by

no test coverage detected