mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Improve default code in Function nodes
This commit is contained in:
@@ -32,7 +32,18 @@ export class Function implements INodeType {
|
||||
rows: 10,
|
||||
},
|
||||
type: 'string',
|
||||
default: 'items[0].json.myVariable = 1;\nreturn items;',
|
||||
default: `// Code here will run only once, no matter how many input items there are.
|
||||
// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function
|
||||
|
||||
// Loop over inputs and add a new field called 'myNewField' to the JSON of each one
|
||||
for (item of items) {
|
||||
item.json.myNewField = 1;
|
||||
}
|
||||
|
||||
// You can write logs to the browser console
|
||||
console.log('Done!');
|
||||
|
||||
return items;`,
|
||||
description: 'The JavaScript code to execute.',
|
||||
noDataExpression: true,
|
||||
},
|
||||
|
||||
@@ -34,7 +34,16 @@ export class FunctionItem implements INodeType {
|
||||
rows: 10,
|
||||
},
|
||||
type: 'string',
|
||||
default: 'item.myVariable = 1;\nreturn item;',
|
||||
default: `// Code here will run once per input item.
|
||||
// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.functionItem
|
||||
|
||||
// Add a new field called 'myNewField' to the JSON of the item
|
||||
item.myNewField = 1;
|
||||
|
||||
// You can write logs to the browser console
|
||||
console.log('Done!');
|
||||
|
||||
return item;`,
|
||||
description: 'The JavaScript code to execute for each item.',
|
||||
noDataExpression: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user