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]
)
| 510 | |
| 511 | |
| 512 | def 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 | |
| 539 | def array_insert(path, # type: str |
no test coverage detected