mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 13:14:07 -08:00
148 lines
3.2 KiB
JSON
148 lines
3.2 KiB
JSON
{
|
|
"nodes": [
|
|
{
|
|
"parameters": {},
|
|
"id": "33eede8d-2ab0-42ab-b79a-a069d8549ab0",
|
|
"name": "When clicking \"Execute Workflow\"",
|
|
"type": "n8n-nodes-base.manualTrigger",
|
|
"typeVersion": 1,
|
|
"position": [-40, 580]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "return[\n { value: 1 },\n { value: 2 },\n]"
|
|
},
|
|
"id": "a5913b52-24dc-4f81-bb7f-f90e61dad978",
|
|
"name": "Sample Data",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 1,
|
|
"position": [200, 580]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Loop over input items and add a new field\n// called 'myNewField' to the JSON of each one\nlet sum = 0;\nfor (const item of $input.all()) {\n sum += item.json.value;\n}\n\nreturn [ {sum} ];"
|
|
},
|
|
"id": "c4ad4913-5af3-42bc-a784-69182f1facdd",
|
|
"name": "Run Once for All Items",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 1,
|
|
"position": [460, 320]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Loop over input items and add a new field\n// called 'myNewField' to the JSON of each one\nlet sum = 0;\nfor (const item of items) {\n sum += item.json.value;\n}\n\nreturn [ {sum} ];"
|
|
},
|
|
"id": "34cbd204-4335-4790-92cd-c3df617eee21",
|
|
"name": "Run Once for All Items (Legacy Syntax)",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 1,
|
|
"position": [460, 500]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"mode": "runOnceForEachItem",
|
|
"jsCode": "// Add a new field called 'myNewField' to the\n// JSON of the item\n$input.item.json.myNewField = $input.item.json.value;\n\nreturn $input.item;"
|
|
},
|
|
"id": "f67d29bf-554a-4572-8867-4456182dec24",
|
|
"name": "Run Once for Each Item",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 1,
|
|
"position": [460, 680]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"mode": "runOnceForEachItem",
|
|
"jsCode": "// Add a new field called 'myNewField' to the\n// JSON of the item\nitem.json.myNewField = item.json.value;\n\nreturn item;"
|
|
},
|
|
"id": "6f4bf149-e84e-4e0d-802a-7eaf7a42b18c",
|
|
"name": "Run Once for Each Item (Legacy Syntax)",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 1,
|
|
"position": [460, 860]
|
|
}
|
|
],
|
|
"pinData": {
|
|
"Run Once for All Items": [
|
|
{
|
|
"json": {
|
|
"sum": 3
|
|
}
|
|
}
|
|
],
|
|
"Run Once for Each Item": [
|
|
{
|
|
"json": {
|
|
"value": 1,
|
|
"myNewField": 1
|
|
}
|
|
},
|
|
{
|
|
"json": {
|
|
"value": 2,
|
|
"myNewField": 2
|
|
}
|
|
}
|
|
],
|
|
"Run Once for All Items (Legacy Syntax)": [
|
|
{
|
|
"json": {
|
|
"sum": 3
|
|
}
|
|
}
|
|
],
|
|
"Run Once for Each Item (Legacy Syntax)": [
|
|
{
|
|
"json": {
|
|
"value": 1,
|
|
"myNewField": 1
|
|
}
|
|
},
|
|
{
|
|
"json": {
|
|
"value": 2,
|
|
"myNewField": 2
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"connections": {
|
|
"When clicking \"Execute Workflow\"": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Sample Data",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Sample Data": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Run Once for All Items",
|
|
"type": "main",
|
|
"index": 0
|
|
},
|
|
{
|
|
"node": "Run Once for Each Item",
|
|
"type": "main",
|
|
"index": 0
|
|
},
|
|
{
|
|
"node": "Run Once for All Items (Legacy Syntax)",
|
|
"type": "main",
|
|
"index": 0
|
|
},
|
|
{
|
|
"node": "Run Once for Each Item (Legacy Syntax)",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
}
|
|
}
|
|
}
|