Class: RecordPatch

x2node-patches~ RecordPatch

Record patch, which is an implementation of RFC 6902 JSON Patch.

new RecordPatch(patchOps, involvedPropPaths, updatedPropPaths)

Note: The constructor is not accessible from the client code. The instances are creating using module's build() function.
Parameters:
Name Type Description
patchOps Array.<module:x2node-patches~RecordPatchOperation> Record patch operations sequence.
involvedPropPaths Set.<string> Involved property paths.
updatedPropPaths Set.<string> Paths of properties directly updated by the patch.

Members


<readonly> involvedPropPaths :Set.<string>

Paths (in dot notation) of all properties involved (read, erased and updated) in the patch.
Type:
  • Set.<string>

<readonly> updatedPropPaths :Set.<string>

Paths (in dot notation) of all properties directly updated by the patch. All are also included in the involvedPropPaths.
Type:
  • Set.<string>

Methods


apply(record [, handlers])

Apply patch to the specified record.
Parameters:
Name Type Argument Description
record Object The record to patch.
handlers module:x2node-patches.RecordPatchHandlers <optional>
Handlers called when a patch operation is applied.
Throws:
If the patch could not be applied because the record is invalid (e.g. missing properties that are expected to be present by the patch logic).
Type
module:x2node-common.X2DataError
Returns:
true if the patch was applied, false if a "test" operation in the patch failed. Note, that in the case of a failed "test" operation the record may be partially modified as this method does not provide transactionality.
Type
boolean