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 numbernumber the number to add - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
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 functionNamestring the name of the function to apply ...argsarguments 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 -
-
concatAfter(appended) → {patchBuilder.ApplyDefinition}
-
Appends a value to the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description appendedstring the string to append - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
concatBefore(prepended) → {patchBuilder.ApplyDefinition}
-
Prepends a value to the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description prependedstring the string to prepend - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
concatBetween(prepended, appended) → {patchBuilder.ApplyDefinition}
-
Prepends and appends values to the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description prependedstring the string to prepend appendedstring the string to append - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
divideBy(divisor) → {patchBuilder.ApplyDefinition}
-
Divides the existing by a number to produce the replace content for a patchBuilder#replace operation.
Parameters:
Name Type Description divisornumber the number to divide by - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
insert(context, position, content, cardinality) → {patchBuilder.PatchOperation}
-
Builds an operation to insert content.
Parameters:
Name Type Argument Description contextstring the path to the container of the inserted content positionstring a specification from the before|after|last-child enumeration controlling where the content will be inserted relative to the context contentthe inserted object or value cardinalitystring <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 -
-
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 moduleNamestring the name of the module with the functions - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
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 multipliernumber the number to multiply by - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
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 languagestring one of the enumeration xpath|jsonpath - Since:
-
- 1.0
Returns:
the specification for the path language -
-
remove(select, cardinality) → {patchBuilder.PatchOperation}
-
Builds an operation to remove a JSON property or XML element or attribute.
Parameters:
Name Type Argument Description selectstring the path to select the fragment to remove cardinalitystring <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 -
-
replace(select, content, cardinality) → {patchBuilder.PatchOperation}
-
Builds an operation to replace a JSON property or XML element or attribute.
Parameters:
Name Type Argument Description selectstring 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 cardinalitystring <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 -
-
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 selectstring the path to select the fragment to replace contextstring the path to the container for inserting the content when the select path doesn't match positionstring 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 cardinalitystring <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 -
-
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 matchstring the expression extracting parts of the existing value endstring the expression to assembling the extracted parts into a replacement value flagsstring <optional>
the flags changing the regex operation - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
substringAfter(start) → {patchBuilder.ApplyDefinition}
-
Trims a leading substring from the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description startstring the leading string to trim - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
substringBefore(end) → {patchBuilder.ApplyDefinition}
-
Trims a trailing substring from the existing value for a patchBuilder#replace operation.
Parameters:
Name Type Description endstring the trailing string to trim - Since:
-
- 1.0
Returns:
the specification for applying a function -
-
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 numbernumber the number to subtract - Since:
-
- 1.0
Returns:
the specification for applying a function
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