Skip to main content

core.applypatch

Home > @medplum/core > applyPatch

applyPatch() function

Apply a 'application/json-patch+json'-type patch to an object.

patch *must* be an array of operations.

Operation objects MUST have exactly one "op" member, whose value indicates the operation to perform. Its value MUST be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors.

This method mutates the target object in-place.

Signature:

export declare function applyPatch(object: any, patch: Operation[], options?: PatchOptions): (null | MissingError | InvalidOperationError | TestError)[];

Parameters

Parameter

Type

Description

object

any

The object to apply the patch to

patch

Operation

Array of operations to apply

options

PatchOptions

(Optional) Optional customization of patch application behavior

Returns:

(null | MissingError | InvalidOperationError | TestError)[]

list of results, one for each operation: null indicated success, otherwise, the result will be an instance of one of the Error classes.