Creates a :class:`.Spec` for adding a value to the end 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 created
(path, # type: str
*values, # type: Iterable[Any]
create_parents=False, # type: Optional[bool]
xattr=False # type: Optional[bool]
)
| 483 | |
| 484 | |
| 485 | def array_append(path, # type: str |
| 486 | *values, # type: Iterable[Any] |
| 487 | create_parents=False, # type: Optional[bool] |
| 488 | xattr=False # type: Optional[bool] |
| 489 | ) -> Spec: |
| 490 | """Creates a :class:`.Spec` for adding a value to the end of an array in a document. |
| 491 | |
| 492 | Args: |
| 493 | path (str): The path to an element of an array. |
| 494 | *values (Iterable[Any]): The values to add. |
| 495 | create_parents (bool, optional): Whether or not the path to the field should be created |
| 496 | if it does not already exist. |
| 497 | xattr (bool, optional): Whether this operation should reference the document body or the |
| 498 | extended attributes data for the document. |
| 499 | |
| 500 | Returns: |
| 501 | :class:`.Spec`: An instance of :class:`.Spec`. |
| 502 | |
| 503 | """ |
| 504 | expand_macros = False |
| 505 | if any(map(lambda m: isinstance(m, MutationMacro), values)): |
| 506 | values = [v.value if isinstance(v, MutationMacro) else v for v in values] |
| 507 | xattr = True |
| 508 | expand_macros = True |
| 509 | return Spec(SubDocOp.ARRAY_PUSH_LAST, path, create_parents, xattr, expand_macros, ArrayValues(*values)) |
| 510 | |
| 511 | |
| 512 | def array_prepend(path, # type: str |
no test coverage detected