Class ObservablePatch

Hierarchy (View Summary)

Constructors

Properties

operations: PatchOperations
selection: PatchSelection

Methods

  • Append the given items to the array at the given JSONPath

    Parameters

    • selector: string

      Attribute/path to append to, eg comments or person.hobbies

    • items: any[]

      Array of items to append to the array

    Returns this

  • Decrement a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.

    Parameters

    • attrs: { [key: string]: number }

      Object of attribute paths to decrement, values representing the number to decrement by.

    Returns this

  • Performs a "diff-match-patch" operation on the string attributes provided. The operation is added to the current patch, ready to be commited by commit()

    Parameters

    • attrs: AttributeSet

      Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: {"nested.prop": "dmp"}

    Returns this

  • Adds a revision clause, preventing the document from being patched if the _rev property does not match the given value

    Parameters

    • rev: string

      Revision to lock the patch to

    Returns this

  • Increment a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.

    Parameters

    • attrs: { [key: string]: number }

      Object of attribute paths to increment, values representing the number to increment by.

    Returns this

  • Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression.

    Parameters

    • at: "before" | "after" | "replace"

      Location to insert at, relative to the given selector, or 'replace' the matched path

    • selector: string

      JSONPath expression, eg comments[-1] or blocks[_key=="abc123"]

    • items: any[]

      Array of items to insert/replace

    Returns this

  • Prepend the given items to the array at the given JSONPath

    Parameters

    • selector: string

      Attribute/path to prepend to, eg comments or person.hobbies

    • items: any[]

      Array of items to prepend to the array

    Returns this

  • Clears the patch of all operations

    Returns this

  • Sets the given attributes to the document. Does NOT merge objects. The operation is added to the current patch, ready to be commited by commit()

    Parameters

    • attrs: AttributeSet

      Attributes to set. To set a deep attribute, use JSONMatch, eg: {"nested.prop": "value"}

    Returns this

  • Sets the given attributes to the document if they are not currently set. Does NOT merge objects. The operation is added to the current patch, ready to be commited by commit()

    Parameters

    • attrs: AttributeSet

      Attributes to set. To set a deep attribute, use JSONMatch, eg: {"nested.prop": "value"}

    Returns this

  • Change the contents of an array by removing existing elements and/or adding new elements.

    Parameters

    • selector: string

      Attribute or JSONPath expression for array

    • start: number

      Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x

    • OptionaldeleteCount: number

      An integer indicating the number of old array elements to remove.

    • Optionalitems: any[]

      The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.

    Returns this

  • Unsets the attribute paths provided. The operation is added to the current patch, ready to be commited by commit()

    Parameters

    • attrs: string[]

      Attribute paths to unset.

    Returns this