Operations

Array operations combine, group, or stage in-memory values for reuse by later Workflow Steps.

The Flowgear Operations Node merges keyed objects, appends arrays, and passes strings, objects, or arrays through unchanged.

Revision History

0.0.0.1 - Initial release.
0.0.0.3 - Added string, object, and array passthrough methods.
0.0.0.5 - Current release.

Setup Notes

You can add this Node to a Workflow without a Connection, authentication, or external setup.

Methods

The Operations Node exposes methods for merging and appending arrays and for passing mapped values through unchanged.

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:

  • Key contains the value used to match records.
  • Value contains 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.

PassthroughString

Stages a string mapping so that you can reuse the unchanged value in multiple later Steps.

Parameter Type Description
ValueIn String The string value to stage.
Return Type Description
ValueOut String The unchanged string value.

PassthroughObject

Stages an object mapping so that you can reuse the unchanged value in multiple later Steps.

Parameter Type Description
ValueIn Object The object value to stage.
Return Type Description
ValueOut Object The unchanged object value.

PassthroughArray

Stages an array mapping so that you can reuse the unchanged values in multiple later Steps.

Parameter Type Description
ValueIn Array The array values to stage.
Return Type Description
ValueOut Array The unchanged array values.

Usage Notes

  • Merge compares Key values. Matching scalar, array, and object values are treated as equal when their content is equal.
  • Merge preserves the order of Array1. Matching values within each returned item preserve their order from Array2.
  • Merge replaces an existing Property on an Array1 Value when that Property has the same name as MergedPropertyName.
  • Merge reads all of Array2 into memory before it processes Array1. Consider the size of Array2 when working with large datasets.
  • Union preserves the order of both inputs and does not remove duplicate values.
  • Use a passthrough method to define a mapping once when several later Steps need the same transformed value.

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" }
]

See also