MergeResults
Description
Section titled “Description”The mergeResults module is an advanced version of Merge that supports nested iterations with hierarchical levels. It collects the results of each processed iteration, stores them in memory (not in the database), and when the last chunk is received, combines all results ordered by index. It supports unique merge keys per iteration level (mergeLevel) and group (mergeGroupKey), which allows correctly handling iterations within other iterations. Each result includes the status (ok/error), the processed record data, and the iteration path.
Configuration
Section titled “Configuration”Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| (no configurable parameters) | - | - | This module does not require additional configuration. It operates automatically based on the _meta_ metadata from the data and the memory context. |
Output
Section titled “Output”{ "nextModule": "siguiente_modulo", "data": { "summary": [ { "index": 0, "status": "ok", "record": { "resultado": "dato1" }, "iterationPath": "0" }, { "index": 1, "status": "ok", "record": { "resultado": "dato2" }, "iterationPath": "1" }, { "index": 2, "status": "error", "record": { "error": "mensaje" }, "iterationPath": "2" } ], "_iterating": false, "mergeInfo": { "level": 0, "groupKey": "uuid-iteracion", "totalItems": 3 } }}Usage Example
Section titled “Usage Example”Basic case
Section titled “Basic case”{ "label": "mergeResults Iterator"}- Uses the context memory system (
ctx.memory) instead of the database to store partial results. - Requires
_meta_.workflowRunIdand_meta_.totalChunksto function. - The memory key is constructed as:
mergeResults_{workflowRunId}_{mergeGroupKey}_{mergeLevel}. - Supports nested iterations thanks to
mergeLevelandmergeGroupKeyin the metadata. - Results are sorted by index before the final output.
- Memory is automatically cleaned up when the merge is complete.
- If chunks are still missing, it returns
nextModule: nullwith_iterating: trueand current progress. - Each result includes
status: "ok"orstatus: "error"depending on whether there were processing errors.
Related Nodes
Section titled “Related Nodes”- Iterator - splits an array into chunks
- Merge - basic version of merge with database
- MergeIterator - simplified merge for iterations
- Repeater - generates repetitions that are later recombined