Expressions and code
Use built-in methods and variables in Duaer
Duaer's built-in methods and variables for working with data in expressions. The Code node runs plain JavaScript and native Luxon.
Expressions and the Code node are not the same engine
The expression editor can use $json, $("Node name"), $now, $if(), and transformation methods on strings, arrays, and dates. The Code node does not use that expression engine.
If the Code node says is not a function, check whether the method exists only in expressions. Date formatting can use format() in an expression; in the Code node, use Luxon’s toFormat(). plus() and minus() accept (amount, unit) in an expression; in the Code node they expect an object such as { days: 7 }. The expression-style call may not throw in the Code node, and still not do what you meant.
$if(), $ifEmpty(), and $jmespath() exist only in expressions. The lookup is Methods and variables reference for Duaer.
Which page to open
- The current item, earlier nodes, conditions, and empty values: Use convenience methods in Duaer expressions.
- Arrays, booleans, dates, numbers, objects, and strings: Use data transformation methods in Duaer.
- HTTP node pagination: Use HTTP node pagination variables in Duaer.
- JSON queries: Query JSON with JMESPath in Duaer.
Questions
Can Duaer transformation methods run in the Code node?
Duaer transformation methods, $if(), and $jmespath() belong to expressions. The Code node runs plain JavaScript and native Luxon. Use toFormat() instead of format(), and plus({ days: 7 }) instead of plus(7, "days").
Which Duaer variable reads the current item?
In a Duaer expression, the current item is $json and its file is $binary. An earlier node is $("Node name").item, first(), last(), or all().
In this section
Use convenience methods in Duaer expressions
In a Duaer expression, use $json for the current item, $("Node name") for an earlier node, and $now and $if() for time and conditions.
TransformUse data transformation methods in Duaer
In a Duaer expression, call a transformation method on a value, such as {{ $json.name.toTitleCase() }}. Methods are grouped by array, boolean, date, number, object, and string.
ExamplesMethods and variables reference for Duaer
Names used most often in a Duaer expression: the current item is $json, an earlier node is $("Node name"), variables are $vars, and transformation methods are grouped by data type.