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

Function increment

couchbase/subdocument.py:624–653  ·  view source on GitHub ↗

Creates a :class:`.Spec` for incrementing the value of a field in a document. Args: path (str): The path to the field. delta (int): The value to increment 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]
              )

Source from the content-addressed store, hash-verified

622
623
624def increment(path, # type: str
625 delta, # type: int
626 xattr=False, # type: Optional[bool]
627 create_parents=False # type: Optional[bool]
628 ) -> Spec:
629 """Creates a :class:`.Spec` for incrementing the value of a field in a document.
630
631 Args:
632 path (str): The path to the field.
633 delta (int): The value to increment from the document.
634 xattr (bool, optional): Whether this operation should reference the document body or the
635 extended attributes data for the document.
636 create_parents (bool, optional): Whether or not the path to the field should be created
637 if it does not already exist.
638
639 Returns:
640 :class:`.Spec`: An instance of :class:`.Spec`.
641
642
643 Raises:
644 :class:`~couchbase.exceptions.InvalidArgumentException`: If the delta arugment is not >= 0 or not
645 of type int.
646 """
647 if not isinstance(delta, int):
648 raise InvalidArgumentException("Delta must be integer")
649 if delta <= 0:
650 raise InvalidArgumentException(
651 "Delta must be integer greater than or equal to 0")
652
653 return Spec(SubDocOp.COUNTER, path, create_parents, xattr, False, delta)
654
655
656def decrement(path, # type: str

Callers 1

counterFunction · 0.85

Calls 2

SpecClass · 0.85

Tested by

no test coverage detected