Creates a :class:`.Spec` for decrementing the value of a field in a document. Args: path (str): The path to the field. delta (int): The value to decrement from the document. xattr (bool, optional): Whether this operation should reference the document body or the
(path, # type: str
delta, # type: int
xattr=False, # type: Optional[bool]
create_parents=False # type: Optional[bool]
)
| 654 | |
| 655 | |
| 656 | def decrement(path, # type: str |
| 657 | delta, # type: int |
| 658 | xattr=False, # type: Optional[bool] |
| 659 | create_parents=False # type: Optional[bool] |
| 660 | ) -> Spec: |
| 661 | """Creates a :class:`.Spec` for decrementing the value of a field in a document. |
| 662 | |
| 663 | Args: |
| 664 | path (str): The path to the field. |
| 665 | delta (int): The value to decrement from the document. |
| 666 | xattr (bool, optional): Whether this operation should reference the document body or the |
| 667 | extended attributes data for the document. |
| 668 | create_parents (bool, optional): Whether or not the path to the field should be created |
| 669 | if it does not already exist. |
| 670 | |
| 671 | Returns: |
| 672 | :class:`.Spec`: An instance of :class:`.Spec`. |
| 673 | |
| 674 | |
| 675 | Raises: |
| 676 | :class:`~couchbase.exceptions.InvalidArgumentException`: If the delta arugment is not >= 0 or not |
| 677 | of type int. |
| 678 | """ |
| 679 | if not isinstance(delta, int): |
| 680 | raise InvalidArgumentException("Delta must be integer") |
| 681 | if delta <= 0: |
| 682 | raise InvalidArgumentException( |
| 683 | "Delta must be integer greater than or equal to 0") |
| 684 | |
| 685 | return Spec(SubDocOp.COUNTER, path, create_parents, xattr, False, -1 * delta) |
| 686 | |
| 687 | |
| 688 | def get_full() -> Spec: |
no test coverage detected