You have been redirected from an outdated version of the article.
Below is the content available on this topic. To view the old article click here.
Aggregate
The Loop or ForEach element are used to iterate over collections of data.
Name |
Description |
Prev |
Accepts another element’s Next socket |
Next |
Connects to another element’s Prev socket |
CurrentData |
Accepts another element’s DataSource . Given data is made available as currentData within the scripting context. |
Data |
Accepts another element’s DataSource . Given data is start value of the aggregation and used to set it’s initial value. |
DataTarget |
Connects to another element’s Prev socket. Contains the aggregated data of the element. |
ExceptionHandler |
If connected to an ExceptionHandler , exceptions thrown in the scripting context will be handled by the referenced handler. |
Script |
StructrScript context used to aggregate the data. Return value will be written to the element’s data. |
Search results for "Aggregate"
Aggregate
The Aggregate element is used to aggregate data within loops in the Flow Engine. It works similar like reduce functions in other languages. In it’s scripting context the keywords data and currentData become available. Data represents the initial value for the aggregation and currentData contains the dataset of the current loop iteration. The script must then process and return the aggregation result and in the next iteration data will contain the result of the previous aggregation.
Name | Description |
Prev | Accepts another element’s Next socket |
Next | Connects to another element’s Prev socket |
CurrentData | Accepts another element’s DataSource . Given data is made available as currentData within the scripting context. |
Data | Accepts another element’s DataSource . Given data is start value of the aggregation and used to set it’s initial value. |
DataTarget | Connects to another element’s DataSource socket. Contains the aggregated data of the element. |
ExceptionHandler | If connected to an ExceptionHandler , exceptions thrown in the scripting context will be handled by the referenced handler. |
Script | context used to aggregate the data. Return value will be written to the element’s data. |
Data Flow and Handling
Whenever a Flow Element has a data source socket available, data can be made available to the element. If such an element has a connected data source, it will query data from it’s source before performing it’s own function. The data source itself can also potentially have another data source, which enables data to be recursively constructed from multiple data elements. In case of elements that allow scripting, the acquired data will be made available under the static data
key. While this is true for all basic elements, Aggregate is a special case, because it takes two data source inputs and makes them available as data
and currentData
based on their respective socket.