Deep Merge
Overview
Deep Merge
merges the enumerable properties of two or more objects deeply.
The step is based on the deepmerge library.
Configuration
path of the object to merge
- adoc
node to be mergedcustom function options
- function to apply to mergecustomMerge
,arrayMerge
orisMergeableObject
customMerge
Specifies a function which can be used to override the default merge behavior for a property, based on the property name.
If no function is provided uses the default behavior.
arrayMerge
There are multiple ways to merge two arrays, choosing this option will allow you to specify how to merge arrays.
isMergeableObject
By default, deepmerge clones every property from almost every kind of object.
You may not want this, if your objects are of special types, and you want to copy the whole object instead of just copying its properties.
You can accomplish this by passing in a function for the isMergeableObject option.
Examples
Input
{
"garden": {
"flowers": [
"roses",
"tulips"
]
},
"yard": {
"flowers": [
"roses",
"tulips",
"orchids"
]
}
}
Step configuration
Input | Value |
---|---|
path | garden |
path | yard |
Custom Function Options | customMerge |
Function | undefined |
Target path | result |
Result
{
"doc": {
"garden": {
"flowers": [
"roses",
"tulips"
]
},
"yard": {
"flowers": [
"roses",
"tulips",
"orchids"
]
},
"result": {
"flowers": [
"roses",
"tulips",
"roses",
"tulips",
"orchids"
]
}
},
"errors": []
}
Example flow
""Sample
{
"name": "exampleDeepMerge",
"flow": {
"name": "exampleDeepMerge",
"description": "",
"steps": [
{
"stepType": "deep-merge",
"color": "rgb(204,255,153)",
"displayName": "Deep Merge",
"isSelected": true,
"config": {
"customFunctionOptionKey": "customMerge",
"objectPaths": [
{
"objectPath": "garden"
},
{
"objectPath": "yard"
}
],
"targetPath": "result"
}
}
]
},
"inputSchema": {
"garden": {
"flowers": [
"roses",
"tulips"
]
},
"yard": {
"flowers": [
"roses",
"tulips",
"orchids"
]
}
},
"createDate": "2021-10-08T17:32:09.863Z",
"id": 1633714329981
}