Operations
Provides methods for combining multiple arrays.
Revision History
0.0.0.1 - Initial release.
Methods
Merge
Combines two arrays by matching a key from each item. Use Merge when you want to group related Array2 records under each Array1 record.
Map every input item to an object with these Properties:
Keycontains the value used to match records.Valuecontains the complete object to include in the result.
The method emits one item for each Array1 item. It copies the Array1 Value and adds an array of matching Array2 values under the Property named by MergedPropertyName. Items without matches receive an empty array.
| Parameter | Type | Description |
|---|---|---|
Array1 |
Array | Keyed values that determine the number and order of the returned items. Map each item to Key and Value Properties. |
Array2 |
Array | Keyed values to match and add to each returned item. Map each item to Key and Value Properties. |
MergedPropertyName |
String | The Property that receives the matching Array2 values. The default is Merged. |
| Return | Type | Description |
|---|---|---|
Items |
Array | The Array1 values with matching Array2 values grouped under MergedPropertyName. |
Union
Appends Array2 to Array1. Use Union when you want one array containing all items from both inputs without matching or grouping them.
Pass the arrays directly. Do not map their items to Key and Value objects.
| Parameter | Type | Description |
|---|---|---|
Array1 |
Array | Values returned first, in their original order. |
Array2 |
Array | Values returned after Array1, in their original order. |
| Return | Type | Description |
|---|---|---|
Items |
Array | All Array1 values followed by all Array2 values. |
Usage Notes
MergecomparesKeyvalues. Matching scalar, array, and object values are treated as equal when their content is equal.Mergepreserves the order ofArray1. Matching values within each returned item preserve their order fromArray2.Mergereplaces an existing Property on anArray1Valuewhen that Property has the same name asMergedPropertyName.Mergereads all ofArray2into memory before it processesArray1. Consider the size ofArray2when working with large datasets.Unionpreserves the order of both inputs and does not remove duplicate values.
Examples
Group books by author with Merge
The sample Workflow first uses JsonStringToArray to create an authors array:
[
{ "id": 1, "name": "Ada" },
{ "id": 2, "name": "Grace" }
]
It creates a second books array:
[
{ "authorId": 1, "title": "Notes" },
{ "authorId": 1, "title": "Sketches" },
{ "authorId": 2, "title": "Compiler" }
]
Configure the Merge parameters with the mappings from the sample:
| Parameter | Property | Expression or value |
|---|---|---|
Array1 |
Key |
{authors.Array.id} |
Array1 |
Value |
{authors.Array} |
Array2 |
Key |
{books.Array.authorId} |
Array2 |
Value |
{books.Array} |
MergedPropertyName |
Books |
The id and authorId values provide the matching keys. The method returns each author and groups the matching books under the Books Property:
[
{
"id": 1,
"name": "Ada",
"Books": [
{ "authorId": 1, "title": "Notes" },
{ "authorId": 1, "title": "Sketches" }
]
},
{
"id": 2,
"name": "Grace",
"Books": [
{ "authorId": 2, "title": "Compiler" }
]
}
]
Append people with Union
The sample Workflow uses JsonStringToArray to create firstPeople:
[
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
It creates a second morePeople array:
[
{ "id": 3, "name": "Carol" }
]
Set Array1 to {firstPeople.Array} and Array2 to {morePeople.Array}. Union returns the first array followed by the second:
[
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" },
{ "id": 3, "name": "Carol" }
]