Namespace: patchBuilder

patchBuilder

A helper for building the definition of a document patch. The helper is created by the marklogic.patchBuilder function.

Members


#collections :patchBuilderCollections

Provides functions that specify patch operations on the collections to which a document belongs.
Type:
Since:
  • 1.0

#metadataValues :patchBuilderMetadataValues

Provides functions that specify patch operations on the metadata values for a document.
Type:
Since:
  • 2.0.1

#permissions :patchBuilderPermissions

Provides functions that specify patch operations on the permissions of a document.
Type:
Since:
  • 1.0

#properties :patchBuilderProperties

Provides functions that specify patch operations on the metadata properties of a document.
Type:
Since:
  • 1.0

#quality :patchBuilderQuality

Provides functions that specify patch operations on the ranking quality of a document.
Type:
Since:
  • 1.0

Methods


add(number) → {patchBuilder.ApplyDefinition}

Adds a number to the existing value to produce the replace content for a patchBuilder#replace operation.
Parameters:
Name Type Description
number number the number to add
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

apply(functionName) → {patchBuilder.ApplyDefinition}

Specifies a function to apply to produce the replacement or insertion content for a patchBuilder#replace or patchBuilder#replaceInsert operation.
Parameters:
Name Type Description
functionName string the name of the function to apply
...args arguments to pass to the applied function; you can use the datatype() function to specify an atomic type in the list prior to a value
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

concatAfter(appended) → {patchBuilder.ApplyDefinition}

Appends a value to the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description
appended string the string to append
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

concatBefore(prepended) → {patchBuilder.ApplyDefinition}

Prepends a value to the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description
prepended string the string to prepend
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

concatBetween(prepended, appended) → {patchBuilder.ApplyDefinition}

Prepends and appends values to the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description
prepended string the string to prepend
appended string the string to append
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

divideBy(divisor) → {patchBuilder.ApplyDefinition}

Divides the existing by a number to produce the replace content for a patchBuilder#replace operation.
Parameters:
Name Type Description
divisor number the number to divide by
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

insert(context, position, content, cardinality) → {patchBuilder.PatchOperation}

Builds an operation to insert content.
Parameters:
Name Type Argument Description
context string the path to the container of the inserted content
position string a specification from the before|after|last-child enumeration controlling where the content will be inserted relative to the context
content the inserted object or value
cardinality string <optional>
a specification from the ?|.|*|+ enumeration controlling whether the context path must match zero-or-one fragment, exactly one fragment, any number of fragments (the default), or one-or-more fragments.
Since:
  • 1.0
Returns:
a patch operation
Type
patchBuilder.PatchOperation

library(moduleName) → {patchBuilder.LibraryParam}

Specifies a library supplying functions to apply to existing content to produce the replacement content as part of patchBuilder#replace or patchBuilder#replaceInsert operations. The library must be installed as /ext/marklogic/patch/apply/MODULE_NAME.xqy or /ext/marklogic/patch/apply/MODULE_NAME.sjs and must have the http://marklogic.com/patch/apply/MODULE_NAME namespace if the library has .xqy extension.
Parameters:
Name Type Description
moduleName string the name of the module with the functions
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.LibraryParam

multiplyBy(multiplier) → {patchBuilder.ApplyDefinition}

Multiplies the existing value by a number to produce the replace content for a patchBuilder#replace operation.
Parameters:
Name Type Description
multiplier number the number to multiply by
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

pathLanguage(language) → {patchBuilder.PathLanguageParam}

Specifies whether the language used in context and select paths for the document patch is XPath or JSONPath. XPath may be used for either JSON or XML documents and is the default path language. JSONPath may only be used for JSON documents. A document patch cannot contain a mix of XPath and JSONPath.
Parameters:
Name Type Description
language string one of the enumeration xpath|jsonpath
Since:
  • 1.0
Returns:
the specification for the path language
Type
patchBuilder.PathLanguageParam

remove(select, cardinality) → {patchBuilder.PatchOperation}

Builds an operation to remove a JSON property or XML element or attribute.
Parameters:
Name Type Argument Description
select string the path to select the fragment to remove
cardinality string <optional>
a specification from the ?|.|*|+ enumeration controlling whether the select path must match zero-or-one fragment, exactly one fragment, any number of fragments (the default), or one-or-more fragments.
Since:
  • 1.0
Returns:
a patch operation
Type
patchBuilder.PatchOperation

replace(select, content, cardinality) → {patchBuilder.PatchOperation}

Builds an operation to replace a JSON property or XML element or attribute.
Parameters:
Name Type Argument Description
select string the path to select the fragment to replace
content <optional>
the object or value replacing the selected fragment or an patchBuilder.ApplyDefinition specifying a function to apply to the selected fragment to produce the replacement
cardinality string <optional>
a specification from the ?|.|*|+ enumeration controlling whether the select path must match zero-or-one fragment, exactly one fragment, any number of fragments (the default), or one-or-more fragments.
Since:
  • 1.0
Returns:
a patch operation
Type
patchBuilder.PatchOperation

replaceInsert(select, context, position, content, cardinality) → {patchBuilder.PatchOperation}

Builds an operation to replace a fragment if the fragment exists and insert the new content if the fragment doesn't exist. The content argument is optional if an apply argument is provided and required otherwise.
Parameters:
Name Type Argument Description
select string the path to select the fragment to replace
context string the path to the container for inserting the content when the select path doesn't match
position string a specification from the before|after|last-child enumeration controlling where the content will be inserted relative to the context
content <optional>
the object or value replacing the selected fragment or, alternatively, inserting within the context or an patchBuilder.ApplyDefinition specifying a function to generate the replacement for the selected fragment or the inserted content
cardinality string <optional>
a specification from the ?|.|*|+ enumeration controlling whether the select or context path must match zero-or-one fragment, exactly one fragment, any number of fragments (the default), or one-or-more fragments.
Since:
  • 1.0
Returns:
a patch operation
Type
patchBuilder.PatchOperation

replaceRegex(match, end, flags) → {patchBuilder.ApplyDefinition}

Applies a regular expression to the existing value to produce a new value for a patchBuilder#replace operation.
Parameters:
Name Type Argument Description
match string the expression extracting parts of the existing value
end string the expression to assembling the extracted parts into a replacement value
flags string <optional>
the flags changing the regex operation
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

substringAfter(start) → {patchBuilder.ApplyDefinition}

Trims a leading substring from the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description
start string the leading string to trim
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

substringBefore(end) → {patchBuilder.ApplyDefinition}

Trims a trailing substring from the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description
end string the trailing string to trim
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

subtract(number) → {patchBuilder.ApplyDefinition}

Subtracts a number from the existing value to produce the replace content for a patchBuilder#replace operation.
Parameters:
Name Type Description
number number the number to subtract
Since:
  • 1.0
Returns:
the specification for applying a function
Type
patchBuilder.ApplyDefinition

Type Definitions


ApplyDefinition

The specification for applying a function to produce the content for a patchBuilder#replace or patchBuilder#replaceInsert operation.
Type:
  • object
Since:
  • 1.0

LibraryParam

The specification for a library of replacement functions as returned by the patchBuilder#library function.
Type:
  • object
Since:
  • 1.0

PatchOperation

An operation as part of a document patch request.
Type:
  • object
Since:
  • 1.0

PathLanguageParam

The specification for whether select and context paths use XPath or JSONPath as returned by the patchBuilder#pathLanguage function.
Type:
  • object
Since:
  • 1.0
Copyright (c) 2020 MarkLogic Corporation Documentation generated by JSDoc 3.6.4 on 2020-08-04T23:55:49-07:00 using the DocStrap template.