mirror of
https://github.com/n8n-io/n8n-docs.git
synced 2026-03-27 09:28:43 +07:00
Refactor Code IA
This commit is contained in:
@@ -24,7 +24,7 @@ From n8n 1.0 onwards, releases will follow the pattern MAJOR.MINOR.PATCH. Versio
|
||||
|
||||
### Python support in the Code node
|
||||
|
||||
Although JavaScript remains the default language, you can now also select Python as an option in the [Code node](/code-examples/javascript-functions/code-node/) and even make use of [many Python modules](https://pyodide.org/en/stable/usage/packages-in-pyodide.html#packages-in-pyodide){:target=_blank .external link}. Note that Python is unavailable in Code nodes added to a workflow before v1.0.
|
||||
Although JavaScript remains the default language, you can now also select Python as an option in the [Code node](/code/code-node/) and even make use of [many Python modules](https://pyodide.org/en/stable/usage/packages-in-pyodide.html#packages-in-pyodide){:target=_blank .external link}. Note that Python is unavailable in Code nodes added to a workflow before v1.0.
|
||||
|
||||
[PR #4295](https://github.com/n8n-io/n8n/pull/4295){:target=_blank .external link}, [PR #6209](https://github.com/n8n-io/n8n/pull/6209){:target=_blank .external link}
|
||||
|
||||
@@ -111,7 +111,7 @@ n8n provides various transformation functions that operate on dates. These funct
|
||||
|
||||
To identify any workflows and nodes that might be impacted by this change, you can use this [utility workflow](https://n8n.io/workflows/1929-v1-helper-find-params-with-affected-expressions/){:target=_blank .external link}.
|
||||
|
||||
For more information about date transformation functions, please refer to the [official documentation](/code-examples/expressions/data-transformation-functions/dates/).
|
||||
For more information about date transformation functions, please refer to the [official documentation](/code/builtin/data-transformation-functions/dates/).
|
||||
|
||||
[PR #6435](https://github.com/n8n-io/n8n/pull/6435){:target=_blank .external link}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
@@ -1,4 +1,25 @@
|
||||
|
||||
# Code into own tab
|
||||
|
||||
/code-examples/ /code/
|
||||
/code-examples/methods-variables-reference/ /code/builtin/
|
||||
/code-examples/expressions/data-transformation-functions/* /code/builtin/data-transformation-functions/:splat
|
||||
/code-examples/javascript-functions/number-items-last-node/ /code/cookbook/code-node/number-items-last-node/
|
||||
/code-examples/javascript-functions/split-binary-file-data/ /code/cookbook/code-node/split-binary-file-data/
|
||||
/code-examples/javascript-functions/get-binary-data-buffer/ /code/cookbook/code-node/get-binary-data-buffer/
|
||||
/code-examples/javascript-functions/console-log/ /code/cookbook/code-node/console-log/
|
||||
/code-examples/ai-code/ /code/ai-code/
|
||||
/code-examples/expressions/check-incoming-data/ /code/cookbook/expressions/check-incoming-data/
|
||||
/code-examples/expressions/understand-expressions/ /code/understand-expressions/
|
||||
/code-examples/javascript-functions/code-node/ /code/code-node/
|
||||
/code-examples/expressions/luxon/ /code/luxon/
|
||||
/code-examples/javascript-functions/luxon/ /code/luxon/
|
||||
/code-examples/expressions/jmespath/ /code/jmespath/
|
||||
/code-examples/javascript-functions/jmespath/ /code/jmespath/
|
||||
/code-examples/methods-variables-examples/* /code/cookbook/builtin/:splat
|
||||
|
||||
###
|
||||
|
||||
/hosting/authentication/user-management-self-hosted/ /hosting/user-management-self-hosted/
|
||||
/hosting/authentication/jwt/ /hosting/user-management-self-hosted/
|
||||
/hosting/authentication/basic-auth/ /hosting/user-management-self-hosted/
|
||||
@@ -13,7 +34,7 @@
|
||||
|
||||
|
||||
/hosting/logging/ /hosting/logging-monitoring/logging/
|
||||
/code-examples/console-log/ /code-examples/javascript-functions/console-log/
|
||||
/code-examples/console-log/ /code/cookbook/code-node/console-log/
|
||||
|
||||
/reference/ /
|
||||
/reference/keyboard-shortcuts/ /keyboard-shortcuts/
|
||||
@@ -60,8 +81,8 @@
|
||||
|
||||
# 2022 SEO audit
|
||||
|
||||
/nodes/expressions/expressions.html /code-examples/expressions/
|
||||
/nodes/expressions.html /code-examples/expressions/
|
||||
/nodes/expressions/expressions.html /code/understand-expressions/
|
||||
/nodes/expressions.html /code/understand-expressions/
|
||||
/reference/configuration.html /hosting/environment-variables/configuration-methods/
|
||||
/getting-started/installation/index.html /hosting/options/
|
||||
/getting-started/create-your-first-workflow/ /try-it-out/
|
||||
@@ -93,10 +114,10 @@
|
||||
|
||||
# methods / vars / paired items
|
||||
|
||||
/code-examples/expressions/methods/ /code-examples/methods-variables-reference/
|
||||
/code-examples/expressions/variables/ /code-examples/methods-variables-reference/
|
||||
/code-examples/javascript-functions/methods/ /code-examples/methods-variables-reference/
|
||||
/code-examples/javascript-functions/variables/ /code-examples/methods-variables-reference/
|
||||
/code-examples/expressions/methods/ /code/builtin/
|
||||
/code-examples/expressions/variables/ /code/builtin/
|
||||
/code-examples/javascript-functions/methods/ /code/builtin/
|
||||
/code-examples/javascript-functions/variables/ /code/builtin/
|
||||
/data/data-mapping/ /data/data-mapping/data-mapping-ui/
|
||||
|
||||
# Editor UI
|
||||
@@ -179,9 +200,6 @@
|
||||
/nodes/creating-nodes/node-review-checklist.html /integrations/creating-nodes/code/review-checklist/
|
||||
/nodes/creating-nodes/troubleshooting.html /integrations/creating-nodes/code/troubleshooting-node-development/
|
||||
|
||||
|
||||
/nodes/expressions/* /code-examples/expressions/:splat
|
||||
|
||||
/nodes/node-basics/ /integrations/
|
||||
/nodes/creating-nodes/ /integrations/creating-nodes/
|
||||
/nodes/credentials/ /integrations/builtin/credentials/
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
---
|
||||
contentType: overview
|
||||
---
|
||||
|
||||
# Expressions
|
||||
|
||||
Expressions are small pieces of JavaScript that allow you to set node parameters dynamically.
|
||||
|
||||
If this is your first time using expressions in n8n, start with [Understand expressions](/code-examples/expressions/understand-expressions/).
|
||||
|
||||
[[% import "_macros/section-toc.html" as sectionToc %]]
|
||||
|
||||
[[ sectionToc.sectionToc(page) ]]
|
||||
@@ -1,166 +0,0 @@
|
||||
---
|
||||
contentType: howto
|
||||
---
|
||||
|
||||
# Date and time with Luxon
|
||||
|
||||
[Luxon](https://github.com/moment/luxon/) is a JavaScript library that makes it easier to work with date and time. For full details of how to use Luxon, refer to [Luxon's documentation](https://moment.github.io/luxon/#/?id=luxon).
|
||||
|
||||
## Variables
|
||||
|
||||
n8n uses Luxon to provide two custom variables:
|
||||
|
||||
- `$now`: a Luxon object containing the current timestamp. Equivalent to `DateTime.now()`.
|
||||
- `$today`: a Luxon object containing the current timestamp, rounded down to the day. Equivalent to `DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 })`.
|
||||
|
||||
Note that these variables can return different time formats when cast as a string. This is the same behavior as Luxon's `DateTime.now()`.
|
||||
|
||||
``` js
|
||||
{{$now}}
|
||||
// n8n displays the ISO formatted timestamp
|
||||
// For example 2022-03-09T14:02:37.065+00:00
|
||||
{{"Today's date is " + $now}}
|
||||
// n8n displays "Today's date is <unix timestamp>"
|
||||
// For example "Today's date is 1646834498755"
|
||||
```
|
||||
|
||||
## Setting the timezone in n8n
|
||||
|
||||
Luxon uses the n8n timezone. This value is either:
|
||||
|
||||
* Default: `America/New York`
|
||||
* A custom timezone for your n8n instance, set using the `GENERIC_TIMEZONE` environment variable.
|
||||
* A custom timezone for an individual workflow, configured in workflow settings.
|
||||
|
||||
## Date and time behavior in n8n
|
||||
|
||||
Be aware of the following:
|
||||
|
||||
* In a workflow, n8n converts dates and times to strings between nodes. Keep this in mind when doing arithmetic on dates and times from other nodes.
|
||||
* With vanilla JavaScript, you can convert a string to a date with `new Date('2019-06-23')`. In Luxon, you must use a function explicitly stating the format, such as `DateTime.fromISO('2019-06-23')` or `DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")`.
|
||||
|
||||
## Common tasks
|
||||
|
||||
This section provides examples for some common operations. More examples, and detailed guidance, are available in [Luxon's own documentation](https://moment.github.io/luxon/#/?id=luxon){:target="_blank" .external-link}.
|
||||
|
||||
### Convert date string to Luxon
|
||||
|
||||
You can convert date strings and other date formats to a Luxon DateTime object. You can convert from standard formats and from arbitrary strings.
|
||||
|
||||
!!! note "A difference between Luxon DateTime and JavaScript Date"
|
||||
With vanilla JavaScript, you can convert a string to a date with `new Date('2019-06-23')`. In Luxon, you must use a function explicitly stating the format, such as `DateTime.fromISO('2019-06-23')` or `DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")`.
|
||||
|
||||
#### If you have a date in a supported standard technical format:
|
||||
|
||||
Most dates use `fromISO()`. This creates a Luxon DateTime from an ISO 8601 string. For example:
|
||||
|
||||
```js
|
||||
{{DateTime.fromISO('2019-06-23T00:00:00.00')}}
|
||||
```
|
||||
|
||||
Luxon's API documentation has more information on [fromISO](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso){:target="_blank" .external-link}.
|
||||
|
||||
Luxon provides functions to handle conversions for a range of formats. Refer to Luxon's guide to [Parsing technical formats](https://moment.github.io/luxon/#/parsing?id=parsing-technical-formats) for details.
|
||||
|
||||
#### If you have a date as a string that doesn't use a standard format:
|
||||
|
||||
Use Luxon's [Ad-hoc parsing](https://moment.github.io/luxon/#/parsing?id=ad-hoc-parsing){:target="_blank" .external-link}. To do this, use the `fromFormat()` function, providing the string and a set of [tokens](https://moment.github.io/luxon/#/parsing?id=table-of-tokens){:target="_blank" .external-link} that describe the format.
|
||||
|
||||
For example, you have n8n's founding date, 23rd June 2019, formatted as '23-06-2019'. You want to turn this into a Luxon object:
|
||||
|
||||
```js
|
||||
{{DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")}}
|
||||
```
|
||||
|
||||
When using ad-hoc parsing, note Luxon's warning about [Limitations](https://moment.github.io/luxon/#/parsing?id=limitations){:target="_blank" .external-link}. If you see unexpected results, try their [Debugging](https://moment.github.io/luxon/#/parsing?id=debugging){:target="_blank" .external-link} guide.
|
||||
|
||||
### Get n days from today
|
||||
|
||||
Get a number of days before or after today.
|
||||
|
||||
For example, you want to set a field to always show the date seven days before the current date.
|
||||
|
||||
In the expressions editor, enter:
|
||||
|
||||
|
||||
``` js
|
||||
{{$today.minus({days: 7})}}
|
||||
```
|
||||
|
||||
On the 23rd June 2019, this returns `[Object: "2019-06-16T00:00:00.000+00:00"]`.
|
||||
|
||||
This example uses n8n's custom variable `$today` for convenience. It's the equivalent of `DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 }).minus({days: 7})`.
|
||||
|
||||
|
||||
For more detailed information and examples, refer to:
|
||||
|
||||
* Luxon's [guide to math](https://moment.github.io/luxon/#/math)
|
||||
* Their API documentation on [DateTime plus](https://moment.github.io/luxon/api-docs/index.html#datetimeplus) and [DateTime minus](https://moment.github.io/luxon/api-docs/index.html#datetimeminus)
|
||||
|
||||
### Create human-readable dates
|
||||
|
||||
In [Get n days from today](#get-n-days-from-today), the example gets the date seven days before the current date, and returns it as `[Object: "yyyy-mm-dd-T00:00:00.000+00:00"]`. To make this more readable, you can use Luxon's formatting functions.
|
||||
|
||||
For example, you want the field containing the date to be formatted as DD/MM/YYYY.
|
||||
|
||||
This expression gets the date seven days before today, and converts it to the DD/MM/YYYY format. So on the 23rd June 2019, it returns 23/06/2019:
|
||||
|
||||
```js
|
||||
{{$today.minus({days: 7}).toLocaleString()}}
|
||||
```
|
||||
|
||||
You can alter the format. For example:
|
||||
|
||||
```js
|
||||
{{$today.minus({days: 7}).toLocaleString({month: 'long', day: 'numeric', year: 'numeric'})}}
|
||||
```
|
||||
|
||||
On 23rd June 2019, this returns "16 June 2019".
|
||||
|
||||
Refer to Luxon's guide on [toLocaleString (strings for humans)](https://moment.github.io/luxon/#/formatting?id=tolocalestring-strings-for-humans){:target="_blank" .external-link} for more information.
|
||||
|
||||
|
||||
### Get the time between two dates
|
||||
|
||||
To get the time between two dates, use Luxon's diffs feature. This subtracts one date from another and returns a duration.
|
||||
|
||||
For example, get the number of months between two dates:
|
||||
|
||||
```js
|
||||
{{DateTime.fromISO('2019-06-23').diff(DateTime.fromISO('2019-05-23'), 'months').toObject()}}
|
||||
```
|
||||
|
||||
This returns `[Object: {"months":1}]`.
|
||||
|
||||
Refer to Luxon's [Diffs](https://moment.github.io/luxon/#/math?id=diffs) for more information.
|
||||
|
||||
### A longer example: How many days to Christmas?
|
||||
|
||||
This example brings together several Luxon features, uses JMESPath, and does some basic string manipulation.
|
||||
|
||||
The scenario: you want a countdown to 25th December. Every day, it should tell you the number of days remaining to Christmas. You don't want to update it for next year - it needs to seamelessly work for every year.
|
||||
|
||||
```js
|
||||
{{"There are " + $today.diff(DateTime.fromISO($today.year + '-12-25'), 'days').toObject().days.toString().substring(1) + " days to Christmas!"}}
|
||||
```
|
||||
|
||||
This outputs `"There are <number of days> days to Christmas!"`. For example, on 9th March, it outputs "There are 291 days to Christmas!".
|
||||
|
||||
A detailed explanation of what the expression does:
|
||||
|
||||
* `{{`: indicates the start of the expression.
|
||||
* `"There are "`: a string.
|
||||
* `+`: used to join two strings.
|
||||
* `$today.diff()`: This is similar to the example in [Get the time between two dates](#get-the-time-between-two-dates), but it uses n8n's custom `$today` variable.
|
||||
* `DateTime.fromISO($today.year + '-12-25'), 'days'`: this part gets the current year using `$today.year`, turns it into an ISO string along with the month and date, and then takes the whole ISO string and converts it to a Luxon DateTime data structure. It also tells Luxon that you want the duration in days.
|
||||
* `toObject()` turns the result of diff() into a more usable object. At this point, the expression returns `[Object: {"days":-<number-of-days>}]`. For example, on 9th March, `[Object: {"days":-291}]`.
|
||||
* `.days` uses JMESPath syntax to retrieve just the number of days from the object. For more information on using JMESPath with n8n, refer to our [JMESpath](/code-examples/expressions/jmespath/) documentation. This gives you the number of days to Christmas, as a negative number.
|
||||
* `.toString().substring(1)` turns the number into a string and removes the `-`.
|
||||
* `+ " days to Christmas!"`: another string, with a `+` to join it to the previous string.
|
||||
* `}}`: indicates the end of the expression.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
---
|
||||
contentType: overview
|
||||
---
|
||||
|
||||
# JavaScript examples
|
||||
|
||||
In n8n, you can write custom JavaScript code within your workflow, using the [Code node](/code-examples/javascript-functions/code-node/).
|
||||
|
||||
[[% import "_macros/section-toc.html" as sectionToc %]]
|
||||
|
||||
[[ sectionToc.sectionToc(page) ]]
|
||||
@@ -1,225 +0,0 @@
|
||||
---
|
||||
contentType: howto
|
||||
---
|
||||
|
||||
# Query JSON with JMESPath
|
||||
|
||||
[JMESPath](https://jmespath.org/) is a query language for JSON, allowing you to extract and transform elements from a JSON document. For full details of how to use JMESPath, refer to the [JMESPath documentation](https://jmespath.org/tutorial.html).
|
||||
|
||||
## The `$jmespath()` method
|
||||
|
||||
n8n provides a custom method, `$jmespath()`. It allows you to perform a search on a JSON object using the JMESPath query language.
|
||||
|
||||
The basic syntax is:
|
||||
|
||||
|
||||
```js
|
||||
$jmespath(object, searchString)
|
||||
```
|
||||
|
||||
|
||||
To help understand what the method does, here is the equivalent longer JavaScript:
|
||||
|
||||
|
||||
```js
|
||||
var jmespath = require('jmespath');
|
||||
jmespath.search(object, searchString);
|
||||
```
|
||||
|
||||
|
||||
`object` is a JSON object, such as the output of a previous node. `searchString` is an expression written in the JMESPath query language. The [JMESPath Specification](https://jmespath.org/specification.html#jmespath-specification){:target=_blank .external-link} provides a list of supported expressions, while their [Tutorial](https://jmespath.org/tutorial.html) and [Examples](https://jmespath.org/examples.html){:target=_blank .external-link} provide interactive examples.
|
||||
|
||||
!!! warning "Search parameter order"
|
||||
The examples in the [JMESPath Specification](https://jmespath.org/specification.html#jmespath-specification){:target=_blank .external-link} follow the pattern `search(searchString, object)`. The [JMESPath JavaScript library](https://github.com/jmespath/jmespath.js/){:target=_blank .external-link}, which n8n uses, supports `search(object, searchString)` instead. This means that when using examples from the JMESPath documentation, you may need to change the order of the search function parameters.
|
||||
|
||||
|
||||
## Common tasks
|
||||
|
||||
This section provides examples for some common operations. More examples, and detailed guidance, are available in [JMESPath's own documentation](https://jmespath.org/tutorial.html){:target=_blank .external-link}.
|
||||
|
||||
|
||||
### Apply a JMESPath expression to a collection of elements with projections
|
||||
|
||||
From the [JMESPath projections documentation](https://jmespath.org/tutorial.html#projections){:target=_blank .external-link}:
|
||||
|
||||
> Projections are one of the key features of JMESPath. It allows you to apply an expression to a collection of elements. JMESPath supports five kinds of projections:
|
||||
>
|
||||
> * List Projections
|
||||
> * Slice Projections
|
||||
> * Object Projections
|
||||
> * Flatten Projections
|
||||
> * Filter Projections
|
||||
|
||||
The following example shows basic usage of list, slice, and object projections. Refer to the [JMESPath projections documentation](https://jmespath.org/tutorial.html#projections){:target=_blank .external-link} for detailed explanations of each projection type, and more examples.
|
||||
|
||||
Given this JSON from a webhook node:
|
||||
|
||||
|
||||
```js
|
||||
[
|
||||
{
|
||||
"headers": {
|
||||
"host": "n8n.instance.address",
|
||||
...
|
||||
},
|
||||
"params": {},
|
||||
"query": {},
|
||||
"body": {
|
||||
"people": [
|
||||
{
|
||||
"first": "James",
|
||||
"last": "Green"
|
||||
},
|
||||
{
|
||||
"first": "Jacob",
|
||||
"last": "Jones"
|
||||
},
|
||||
{
|
||||
"first": "Jayden",
|
||||
"last": "Smith"
|
||||
}
|
||||
],
|
||||
"dogs": {
|
||||
"Fido": {
|
||||
"color": "brown",
|
||||
"age": 7
|
||||
},
|
||||
"Spot": {
|
||||
"color": "black and white",
|
||||
"age": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
|
||||
Retrieve a [list](https://jmespath.org/tutorial.html#list-and-slice-projections){:target=_blank .external-link} of all the people's first names:
|
||||
|
||||
|
||||
```js
|
||||
$jmespath($json.body.people, "[*].first" )
|
||||
/* Returns:
|
||||
[
|
||||
{
|
||||
"firstNames": [
|
||||
"James",
|
||||
"Jacob",
|
||||
"Jayden"
|
||||
]
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
Get a [slice](https://jmespath.org/tutorial.html#list-and-slice-projections){:target=_blank .external-link} of the first names:
|
||||
|
||||
|
||||
```js
|
||||
$jmespath($json.body.people, "[:2].first")
|
||||
/* Returns:
|
||||
[
|
||||
{
|
||||
"firstNames": [
|
||||
"James",
|
||||
"Jacob",
|
||||
"Jayden"
|
||||
]
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
Get a list of the dogs' ages using [object projections](https://jmespath.org/tutorial.html#object-projections){:target=_blank .external-link}:
|
||||
|
||||
|
||||
```js
|
||||
$jmespath($json.body.dogs, "*.age")
|
||||
/* Returns:
|
||||
[
|
||||
7,
|
||||
5
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
### Select multiple elements and create a new list or object
|
||||
|
||||
[Multiselect](https://jmespath.org/tutorial.html#multiselect){:target=_blank .external-link} allows you to select elements from a JSON object and combine them into a new list or object.
|
||||
|
||||
Given this JSON from a webhook node:
|
||||
|
||||
|
||||
```js
|
||||
[
|
||||
{
|
||||
"headers": {
|
||||
"host": "n8n.instance.address",
|
||||
...
|
||||
},
|
||||
"params": {},
|
||||
"query": {},
|
||||
"body": {
|
||||
"people": [
|
||||
{
|
||||
"first": "James",
|
||||
"last": "Green"
|
||||
},
|
||||
{
|
||||
"first": "Jacob",
|
||||
"last": "Jones"
|
||||
},
|
||||
{
|
||||
"first": "Jayden",
|
||||
"last": "Smith"
|
||||
}
|
||||
],
|
||||
"dogs": {
|
||||
"Fido": {
|
||||
"color": "brown",
|
||||
"age": 7
|
||||
},
|
||||
"Spot": {
|
||||
"color": "black and white",
|
||||
"age": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
|
||||
Use multiselect list to get the first and last names and create new lists containing both names:
|
||||
|
||||
|
||||
```js
|
||||
$jmespath($json.body.people, "[].[first, last]")
|
||||
/* Returns:
|
||||
[
|
||||
{
|
||||
"fullNames": [
|
||||
[
|
||||
"James",
|
||||
"Green"
|
||||
],
|
||||
[
|
||||
"Jacob",
|
||||
"Jones"
|
||||
],
|
||||
[
|
||||
"Jayden",
|
||||
"Smith"
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
---
|
||||
contentType: howto
|
||||
---
|
||||
|
||||
# Date and time with Luxon
|
||||
|
||||
[Luxon](https://github.com/moment/luxon/) is a JavaScript library that makes it easier to work with date and time. For full details of how to use Luxon, refer to [Luxon's documentation](https://moment.github.io/luxon/#/?id=luxon).
|
||||
|
||||
## Variables
|
||||
|
||||
n8n uses Luxon to provide two custom variables:
|
||||
|
||||
- `$now`: a Luxon object containing the current timestamp. Equivalent to `DateTime.now()`.
|
||||
- `$today`: a Luxon object containing the current timestamp, rounded down to the day. Equivalent to `DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 })`.
|
||||
|
||||
Note that these variables can return different time formats when cast as a string. This is the same behavior as Luxon's `DateTime.now()`.
|
||||
|
||||
|
||||
``` js
|
||||
$now
|
||||
// n8n displays <ISO formatted timestamp>
|
||||
// For example 2022-03-09T14:00:25.058+00:00
|
||||
"Today's date is " + $now
|
||||
// n8n displays "Today's date is <unix timestamp>"
|
||||
// For example "Today's date is 1646834498755"
|
||||
```
|
||||
|
||||
## Setting the timezone in n8n
|
||||
|
||||
Luxon uses the n8n timezone. This value is either:
|
||||
|
||||
* Default: `America/New York`
|
||||
* A custom timezone for your n8n instance, set using the `GENERIC_TIMEZONE` environment variable.
|
||||
* A custom timezone for an individual workflow, configured in workflow settings.
|
||||
|
||||
## Date and time behavior in n8n
|
||||
|
||||
Be aware of the following:
|
||||
|
||||
* In a workflow, n8n converts dates and times to strings between nodes. Keep this in mind when doing arithmetic on dates and times from other nodes.
|
||||
* With vanilla JavaScript, you can convert a string to a date with `new Date('2019-06-23')`. In Luxon, you must use a function explicitly stating the format, such as `DateTime.fromISO('2019-06-23')` or `DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")`.
|
||||
|
||||
## Common tasks
|
||||
|
||||
This section provides examples for some common operations. More examples, and detailed guidance, are available in [Luxon's own documentation](https://moment.github.io/luxon/#/?id=luxon){:target="_blank" .external-link}.
|
||||
|
||||
### Convert date string to Luxon
|
||||
|
||||
You can convert date strings and other date formats to a Luxon DateTime object. You can convert from standard formats and from arbitrary strings.
|
||||
|
||||
!!! note "A difference between Luxon DateTime and JavaScript Date"
|
||||
With vanilla JavaScript, you can convert a string to a date with `new Date('2019-06-23')`. In Luxon, you must use a function explicitly stating the format, such as `DateTime.fromISO('2019-06-23')` or `DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")`.
|
||||
|
||||
#### If you have a date in a supported standard technical format:
|
||||
|
||||
Most dates use `fromISO()`. This creates a Luxon DateTime from an ISO 8601 string. For example:
|
||||
|
||||
```js
|
||||
let luxonDateTime = DateTime.fromISO('2019-06-23T00:00:00.00')'
|
||||
```
|
||||
|
||||
Luxon's API documentation has more information on [fromISO](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso){:target="_blank" .external-link}.
|
||||
|
||||
Luxon provides functions to handle conversions for a range of formats. Refer to Luxon's guide to [Parsing technical formats](https://moment.github.io/luxon/#/parsing?id=parsing-technical-formats) for details.
|
||||
|
||||
#### If you have a date as a string that doesn't use a standard format:
|
||||
|
||||
Use Luxon's [Ad-hoc parsing](https://moment.github.io/luxon/#/parsing?id=ad-hoc-parsing){:target="_blank" .external-link}. To do this, use the `fromFormat()` function, providing the string and a set of [tokens](https://moment.github.io/luxon/#/parsing?id=table-of-tokens){:target="_blank" .external-link} that describe the format.
|
||||
|
||||
For example, you have n8n's founding date, 23rd June 2019, formatted as '23-06-2019'. You want to turn this into a Luxon object:
|
||||
|
||||
```js
|
||||
let newFormat = DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")
|
||||
```
|
||||
|
||||
When using ad-hoc parsing, note Luxon's warning about [Limitations](https://moment.github.io/luxon/#/parsing?id=limitations){:target="_blank" .external-link}. If you see unexpected results, try their [Debugging](https://moment.github.io/luxon/#/parsing?id=debugging){:target="_blank" .external-link} guide.
|
||||
|
||||
### Get n days from today
|
||||
|
||||
Get a number of days before or after today.
|
||||
|
||||
For example, you want a variable containing the date seven days before the current date.
|
||||
|
||||
In the code editor, enter:
|
||||
|
||||
``` js
|
||||
let sevenDaysAgo = $today.minus({days: 7})
|
||||
```
|
||||
|
||||
On the 23rd June 2019, this returns `[Object: "2019-06-16T00:00:00.000+00:00"]`.
|
||||
|
||||
This example uses n8n's custom variable `$today` for convenience. It's the equivalent of `DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 }).minus({days: 7})`.
|
||||
|
||||
|
||||
For more detailed information and examples, refer to:
|
||||
|
||||
* Luxon's [guide to math](https://moment.github.io/luxon/#/math)
|
||||
* Their API documentation on [DateTime plus](https://moment.github.io/luxon/api-docs/index.html#datetimeplus) and [DateTime minus](https://moment.github.io/luxon/api-docs/index.html#datetimeminus)
|
||||
|
||||
### Create human-readable dates
|
||||
|
||||
In [Get n days from today](#get-n-days-from-today), the example gets the date seven days before the current date, and returns it as `yyyy-mm-dd-T00:00:00.000+00:00`. To make this more readable, you can use Luxon's formatting functions.
|
||||
|
||||
For example, you want the field containing the date to be formatted as DD/MM/YYYY, so that on the 23rd June 2019, it returns 23/06/2019
|
||||
|
||||
This expression gets the date seven days before today, and converts it to the DD/MM/YYYY format.
|
||||
|
||||
```js
|
||||
let readableSevenDaysAgo = $today.minus({days: 7}).toLocaleString()
|
||||
```
|
||||
|
||||
You can alter the format. For example:
|
||||
|
||||
```js
|
||||
let readableSevenDaysAgo = $today.minus({days: 7}).toLocaleString({month: 'long', day: 'numeric', year: 'numeric'})
|
||||
```
|
||||
|
||||
On 23rd June 2019, this returns "16 June 2019".
|
||||
|
||||
Refer to Luxon's guide on [toLocaleString (strings for humans)](https://moment.github.io/luxon/#/formatting?id=tolocalestring-strings-for-humans){:target="_blank" .external-link} for more information.
|
||||
|
||||
|
||||
### Get the time between two dates
|
||||
|
||||
To get the time between two dates, use Luxon's diffs feature. This subtracts one date from another and returns a duration.
|
||||
|
||||
For example, get the number of months between two dates:
|
||||
|
||||
```js
|
||||
let monthsBetweenDates = DateTime.fromISO('2019-06-23').diff(DateTime.fromISO('2019-05-23'), 'months').toObject()
|
||||
```
|
||||
|
||||
This returns `{"months":1}`.
|
||||
|
||||
Refer to Luxon's [Diffs](https://moment.github.io/luxon/#/math?id=diffs) for more information.
|
||||
|
||||
### A longer example: How many days to Christmas?
|
||||
|
||||
This example brings together several Luxon features, uses JMESPath, and does some basic string manipulation.
|
||||
|
||||
The scenario: you want a countdown to 25th December. Every day, it should tell you the number of days remaining to Christmas. You don't want to update it for next year - it needs to seamelessly work for every year.
|
||||
|
||||
```js
|
||||
let daysToChristmas = "There are " + $today.diff(DateTime.fromISO($today.year + '-12-25'), 'days').toObject().days.toString().substring(1) + " days to Christmas!";
|
||||
```
|
||||
|
||||
This outputs `"There are <number of days> days to Christmas!"`. For example, on 9th March, it outputs "There are 291 days to Christmas!".
|
||||
|
||||
A detailed explanation of what the code does:
|
||||
|
||||
* `"There are "`: a string.
|
||||
* `+`: used to join two strings.
|
||||
* `$today.diff()`: This is similar to the example in [Get the time between two dates](#get-the-time-between-two-dates), but it uses n8n's custom `$today` variable.
|
||||
* `DateTime.fromISO($today.year + '-12-25'), 'days'`: this part gets the current year using `$today.year`, turns it into an ISO string along with the month and date, and then takes the whole ISO string and converts it to a Luxon DateTime data structure. It also tells Luxon that you want the duration in days.
|
||||
* `toObject()` turns the result of diff() into a more usable object. At this point, the expression returns `[Object: {"days":-<number-of-days>}]`. For example, on 9th March, `[Object: {"days":-291}]`.
|
||||
* `.days` uses JMESPath syntax to retrieve just the number of days from the object. For more information on using JMESPath with n8n, refer to our [JMESpath](/code-examples/javascript-functions/jmespath/) documentation. This gives you the number of days to Christmas, as a negative number.
|
||||
* `.toString().substring(1)` turns the number into a string and removes the `-`.
|
||||
* `+ " days to Christmas!"`: another string, with a `+` to join it to the previous string.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ contentType: explanation
|
||||
|
||||
## Use AI in the Code node
|
||||
|
||||
--8<-- "_snippets/code-examples/ai-how-to.md"
|
||||
--8<-- "_snippets/code/ai-how-to.md"
|
||||
|
||||
## Usage limits
|
||||
|
||||
@@ -44,7 +44,7 @@ Some general tips:
|
||||
|
||||
And some n8n-specific guidance:
|
||||
|
||||
* Think about the input data: make sure ChatGPT knows which pieces of the data you want to access, and what the incoming data represents. You may need to tell ChatGPT about the availability of n8n's [Built-in methods and variables](/code-examples/methods-variables-reference/).
|
||||
* Think about the input data: make sure ChatGPT knows which pieces of the data you want to access, and what the incoming data represents. You may need to tell ChatGPT about the availability of n8n's [Built-in methods and variables](/code/builtin/).
|
||||
* Declare interactions between nodes: if your logic involves data from multiple nodes, specify how they should interact. "Merge the output of 'Node A' with 'Node B' based on the 'userID' property". if you prefer data to come from certain nodes or to ignore others, be clear: "Only consider data from the 'Purchases' node and ignore the 'Refunds' node."
|
||||
* Ensure the output is compatible with n8n. Refer to [Data structure](/data/data-structure/) for more information on the data structure n8n requires.
|
||||
|
||||
@@ -156,7 +156,7 @@ return [{ json: { slackMessage } }];
|
||||
|
||||
If your incoming data contains nested fields, using dot notation to reference them can help the AI understand what data you want.
|
||||
|
||||

|
||||

|
||||
|
||||
To try the example yourself, [download the example workflow](/_workflows/ai-code/reference-incoming-data-explicitly.json) and import it into n8n.
|
||||
|
||||
@@ -189,4 +189,4 @@ Pluralsight offer a short guide on [How to use ChatGPT to write code](https://ww
|
||||
|
||||
## Fixing the code
|
||||
|
||||
The AI-generated code may work without any changes, but you may have to edit it. You need to be aware of n8n's [Data structure](/data/data-structure/). You may also find n8n's [Built-in methods and variables](/code-examples/methods-variables-reference/) useful.
|
||||
The AI-generated code may work without any changes, but you may have to edit it. You need to be aware of n8n's [Data structure](/data/data-structure/). You may also find n8n's [Built-in methods and variables](/code/builtin/) useful.
|
||||
@@ -13,11 +13,11 @@ Data transformation functions are helper functions to make data transformation e
|
||||
|
||||
For a list of available functions, refer to the page for your data type:
|
||||
|
||||
* [Arrays](/code-examples/expressions/data-transformation-functions/arrays/)
|
||||
* [Dates](/code-examples/expressions/data-transformation-functions/dates/)
|
||||
* [Numbers](/code-examples/expressions/data-transformation-functions/numbers/)
|
||||
* [Objects](/code-examples/expressions/data-transformation-functions/objects/)
|
||||
* [Strings](/code-examples/expressions/data-transformation-functions/strings/)
|
||||
* [Arrays](/code/builtin/data-transformation-functions/arrays/)
|
||||
* [Dates](/code/builtin/data-transformation-functions/dates/)
|
||||
* [Numbers](/code/builtin/data-transformation-functions/numbers/)
|
||||
* [Objects](/code/builtin/data-transformation-functions/objects/)
|
||||
* [Strings](/code/builtin/data-transformation-functions/strings/)
|
||||
|
||||
## Usage
|
||||
|
||||
0
docs/code/builtin/index.md
Normal file
0
docs/code/builtin/index.md
Normal file
@@ -68,7 +68,7 @@ This includes:
|
||||
| `$execution.id` | The unique ID of the current workflow execution. | :white_check_mark: |
|
||||
| `$execution.mode` | Whether the execution was triggered automatically, or by manually running the workflow. Possible values are `test` and `production`. | :white_check_mark: |
|
||||
| `$execution.resumeUrl` | The webhook URL to call to resume a workflow waiting at a [Wait node](/integrations/builtin/core-nodes/n8n-nodes-base.wait/). | :white_check_mark: |
|
||||
| `$getWorkflowStaticData(type)` | View an [example](/code-examples/methods-variables-examples/get-workflow-static-data/). Static data doesn't persist when testing workflows. The workflow must be active and called by a trigger or webhook to save static data. This gives access to the static workflow data. | :white_check_mark: |
|
||||
| `$getWorkflowStaticData(type)` | View an [example](/code/cookbook/builtin/get-workflow-static-data/). Static data doesn't persist when testing workflows. The workflow must be active and called by a trigger or webhook to save static data. This gives access to the static workflow data. | :white_check_mark: |
|
||||
| `$itemIndex` | The index of an item in a list of items. | :x: |
|
||||
| `$prevNode.name` | The name of the node that the current input came from. When using the Merge node, note that `$prevNode` always uses the first input connector. | :white_check_mark: |
|
||||
| `$prevNode.outputIndex` | The index of the output connector that the current input came from. Use this when the previous node had multiple outputs (such as an If or Switch node). When using the Merge node, note that `$prevNode` always uses the first input connector. | :white_check_mark: |
|
||||
0
docs/code/cookbook/code-node/index.md
Normal file
0
docs/code/cookbook/code-node/index.md
Normal file
0
docs/code/cookbook/expressions/index.md
Normal file
0
docs/code/cookbook/expressions/index.md
Normal file
0
docs/code/cookbook/index.md
Normal file
0
docs/code/cookbook/index.md
Normal file
@@ -15,7 +15,7 @@ There are two places in your workflows where you can use code:
|
||||
|
||||
- __Expressions__
|
||||
|
||||
Use expressions to transform [data](/data/) in your nodes. You can use JavaScript in expressions, as well as n8n's [Built-in methods and variables](/code-examples/methods-variables-reference/) and [Data transformation functions](/code-examples/expressions/data-transformation-functions/).
|
||||
Use expressions to transform [data](/data/) in your nodes. You can use JavaScript in expressions, as well as n8n's [Built-in methods and variables](/code/builtin/) and [Data transformation functions](/code/builtin/data-transformation-functions/).
|
||||
|
||||
[:octicons-arrow-right-24: Expressions](/code-examples/expressions/)
|
||||
|
||||
@@ -23,7 +23,7 @@ There are two places in your workflows where you can use code:
|
||||
|
||||
The Code node allows you to add JavaScript to your workflow.
|
||||
|
||||
[:octicons-arrow-right-24: Code node](/code-examples/javascript-functions/code-node/)
|
||||
[:octicons-arrow-right-24: Code node](/code/code-node/)
|
||||
|
||||
</div>
|
||||
|
||||
@@ -35,7 +35,7 @@ n8n provides core nodes, which simplify adding key functionality such as API req
|
||||
|
||||
- __Write a backend__
|
||||
|
||||
The [HTTP Request](/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/), [Webhook](/integrations/builtin/core-nodes/n8n-nodes-base.webhook/), and [Code](/code-examples/javascript-functions/code-node/) nodes help you make API calls, respond to webhooks, and write any JavaScript in your workflow.
|
||||
The [HTTP Request](/integrations/builtin/core-nodes/n8n-nodes-base.httprequest/), [Webhook](/integrations/builtin/core-nodes/n8n-nodes-base.webhook/), and [Code](/code/code-node/) nodes help you make API calls, respond to webhooks, and write any JavaScript in your workflow.
|
||||
|
||||
This allows you to do things like [Create an API endpoint](https://n8n.io/workflows/1750-creating-an-api-endpoint/){:target=_blank .external-link}.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
---
|
||||
title: Query JSON with JMESPath
|
||||
description: n8n supports the JMESPath library, to simplify working with JSON formatted data.
|
||||
contentType: howto
|
||||
---
|
||||
|
||||
@@ -8,7 +10,7 @@ contentType: howto
|
||||
|
||||
## The `$jmespath()` method
|
||||
|
||||
n8n provides a custom method, `$jmespath()`, for use in expressions. It allows you to perform a search on a JSON object using the JMESPath query language.
|
||||
n8n provides a custom method, `$jmespath()`. It allows you to perform a search on a JSON object using the JMESPath query language.
|
||||
|
||||
The basic syntax is:
|
||||
|
||||
@@ -18,7 +20,7 @@ $jmespath(object, searchString)
|
||||
```
|
||||
|
||||
|
||||
To help understand what the method does, here is the equivalent JavaScript. Note that you must use the custom method, not the JavaScript approach, because expressions must be single-line:
|
||||
To help understand what the method does, here is the equivalent longer JavaScript:
|
||||
|
||||
|
||||
```js
|
||||
@@ -26,8 +28,11 @@ var jmespath = require('jmespath');
|
||||
jmespath.search(object, searchString);
|
||||
```
|
||||
|
||||
!!! note "Expressions must be single-line"
|
||||
The longer code example doesn't work in Expressions, as they must be single-line.
|
||||
|
||||
`object` is a JSON object, such as the output of a previous node. `searchString` is an expression written in the JMESPath query language. The [JMESPath Specification](https://jmespath.org/specification.html#jmespath-specification) provides a list of supported expressions, while their [Tutorial](https://jmespath.org/tutorial.html) and [Examples](https://jmespath.org/examples.html) provide interactive examples.
|
||||
|
||||
`object` is a JSON object, such as the output of a previous node. `searchString` is an expression written in the JMESPath query language. The [JMESPath Specification](https://jmespath.org/specification.html#jmespath-specification){:target=_blank .external-link} provides a list of supported expressions, while their [Tutorial](https://jmespath.org/tutorial.html) and [Examples](https://jmespath.org/examples.html){:target=_blank .external-link} provide interactive examples.
|
||||
|
||||
!!! warning "Search parameter order"
|
||||
The examples in the [JMESPath Specification](https://jmespath.org/specification.html#jmespath-specification){:target=_blank .external-link} follow the pattern `search(searchString, object)`. The [JMESPath JavaScript library](https://github.com/jmespath/jmespath.js/){:target=_blank .external-link}, which n8n uses, supports `search(object, searchString)` instead. This means that when using examples from the JMESPath documentation, you may need to change the order of the search function parameters.
|
||||
@@ -39,9 +44,9 @@ This section provides examples for some common operations. More examples, and de
|
||||
|
||||
### Apply a JMESPath expression to a collection of elements with projections
|
||||
|
||||
From the [JMESPath projections documentation](https://jmespath.org/tutorial.html#projections):
|
||||
From the [JMESPath projections documentation](https://jmespath.org/tutorial.html#projections){:target=_blank .external-link}:
|
||||
|
||||
> Projections are one of the key features of JMESPath. It allows you to apply an expression to a collection of elements. There are five kinds of projections:
|
||||
> Projections are one of the key features of JMESPath. It allows you to apply an expression to a collection of elements. JMESPath supports five kinds of projections:
|
||||
>
|
||||
> * List Projections
|
||||
> * Slice Projections
|
||||
@@ -49,7 +54,7 @@ From the [JMESPath projections documentation](https://jmespath.org/tutorial.html
|
||||
> * Flatten Projections
|
||||
> * Filter Projections
|
||||
|
||||
The following example shows basic usage of list, slice, and object projections. Refer to the [JMESPath projections documentation](https://jmespath.org/tutorial.html#projections) for detailed explanations of each projection type, and more examples.
|
||||
The following example shows basic usage of list, slice, and object projections. Refer to the [JMESPath projections documentation](https://jmespath.org/tutorial.html#projections){:target=_blank .external-link} for detailed explanations of each projection type, and more examples.
|
||||
|
||||
Given this JSON from a webhook node:
|
||||
|
||||
@@ -95,32 +100,77 @@ Given this JSON from a webhook node:
|
||||
```
|
||||
|
||||
|
||||
Retrieve a [list](https://jmespath.org/tutorial.html#list-and-slice-projections) of all the people's first names:
|
||||
Retrieve a [list](https://jmespath.org/tutorial.html#list-and-slice-projections){:target=_blank .external-link} of all the people's first names:
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{$jmespath($json.body.people, "[*].first" )}}
|
||||
// Returns ["James", "Jacob", "Jayden"]
|
||||
```js
|
||||
{{$jmespath($json.body.people, "[*].first" )}}
|
||||
// Returns ["James", "Jacob", "Jayden"]
|
||||
```
|
||||
|
||||
=== "Code node"
|
||||
|
||||
```js
|
||||
$jmespath($json.body.people, "[*].first" )
|
||||
/* Returns:
|
||||
[
|
||||
{
|
||||
"firstNames": [
|
||||
"James",
|
||||
"Jacob",
|
||||
"Jayden"
|
||||
]
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
Get a [slice](https://jmespath.org/tutorial.html#list-and-slice-projections){:target=_blank .external-link} of the first names:
|
||||
|
||||
Get a [slice](https://jmespath.org/tutorial.html#list-and-slice-projections) of the first names:
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{$jmespath($json.body.people, "[:2].first")}}
|
||||
// Returns ["James", "Jacob"]
|
||||
```
|
||||
|
||||
```js
|
||||
{{$jmespath($json.body.people, "[:2].first")}}
|
||||
// Returns ["James", "Jacob"]
|
||||
=== "Code node"
|
||||
```js
|
||||
$jmespath($json.body.people, "[:2].first")
|
||||
/* Returns:
|
||||
[
|
||||
{
|
||||
"firstNames": [
|
||||
"James",
|
||||
"Jacob",
|
||||
"Jayden"
|
||||
]
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
Get a list of the dogs' ages using [object projections](https://jmespath.org/tutorial.html#object-projections){:target=_blank .external-link}:
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{$jmespath($json.body.dogs, "*.age")}}
|
||||
// Returns [7,5]
|
||||
```
|
||||
|
||||
=== "Code node"
|
||||
```js
|
||||
$jmespath($json.body.dogs, "*.age")
|
||||
/* Returns:
|
||||
[
|
||||
7,
|
||||
5
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
Get a list of the dogs' ages using [object projections](https://jmespath.org/tutorial.html#object-projections):
|
||||
|
||||
|
||||
```js
|
||||
{{$jmespath($json.body.dogs, "*.age")}}
|
||||
// Returns [7,5]
|
||||
```
|
||||
|
||||
|
||||
### Select multiple elements and create a new list or object
|
||||
|
||||
[Multiselect](https://jmespath.org/tutorial.html#multiselect){:target=_blank .external-link} allows you to select elements from a JSON object and combine them into a new list or object.
|
||||
@@ -171,13 +221,40 @@ Given this JSON from a webhook node:
|
||||
|
||||
Use multiselect list to get the first and last names and create new lists containing both names:
|
||||
|
||||
[[% raw %]]
|
||||
```js
|
||||
{{$jmespath($json.body.people, "[].[first, last]")}}
|
||||
// Returns [["James","Green"],["Jacob","Jones"],["Jayden","Smith"]]
|
||||
```
|
||||
[[% endraw %]]
|
||||
=== "Expressions"
|
||||
|
||||
[[% raw %]]
|
||||
```js
|
||||
{{$jmespath($json.body.people, "[].[first, last]")}}
|
||||
// Returns [["James","Green"],["Jacob","Jones"],["Jayden","Smith"]]
|
||||
```
|
||||
[[% endraw %]]
|
||||
|
||||
=== "Code node"
|
||||
|
||||
```js
|
||||
$jmespath($json.body.people, "[].[first, last]")
|
||||
/* Returns:
|
||||
[
|
||||
{
|
||||
"fullNames": [
|
||||
[
|
||||
"James",
|
||||
"Green"
|
||||
],
|
||||
[
|
||||
"Jacob",
|
||||
"Jones"
|
||||
],
|
||||
[
|
||||
"Jayden",
|
||||
"Smith"
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
### An alternative to arrow functions
|
||||
|
||||
252
docs/code/luxon.md
Normal file
252
docs/code/luxon.md
Normal file
@@ -0,0 +1,252 @@
|
||||
---
|
||||
contentType: howto
|
||||
---
|
||||
|
||||
# Date and time with Luxon
|
||||
|
||||
[Luxon](https://github.com/moment/luxon/) is a JavaScript library that makes it easier to work with date and time. For full details of how to use Luxon, refer to [Luxon's documentation](https://moment.github.io/luxon/#/?id=luxon).
|
||||
|
||||
## Variables
|
||||
|
||||
n8n uses Luxon to provide two custom variables:
|
||||
|
||||
- `$now`: a Luxon object containing the current timestamp. Equivalent to `DateTime.now()`.
|
||||
- `$today`: a Luxon object containing the current timestamp, rounded down to the day. Equivalent to `DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 })`.
|
||||
|
||||
Note that these variables can return different time formats when cast as a string. This is the same behavior as Luxon's `DateTime.now()`.
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
``` js
|
||||
{{$now}}
|
||||
// n8n displays the ISO formatted timestamp
|
||||
// For example 2022-03-09T14:02:37.065+00:00
|
||||
{{"Today's date is " + $now}}
|
||||
// n8n displays "Today's date is <unix timestamp>"
|
||||
// For example "Today's date is 1646834498755"
|
||||
```
|
||||
|
||||
=== "Code node"
|
||||
|
||||
``` js
|
||||
$now
|
||||
// n8n displays <ISO formatted timestamp>
|
||||
// For example 2022-03-09T14:00:25.058+00:00
|
||||
"Today's date is " + $now
|
||||
// n8n displays "Today's date is <unix timestamp>"
|
||||
// For example "Today's date is 1646834498755"
|
||||
```
|
||||
|
||||
## Setting the timezone in n8n
|
||||
|
||||
Luxon uses the n8n timezone. This value is either:
|
||||
|
||||
* Default: `America/New York`
|
||||
* A custom timezone for your n8n instance, set using the `GENERIC_TIMEZONE` environment variable.
|
||||
* A custom timezone for an individual workflow, configured in workflow settings.
|
||||
|
||||
## Date and time behavior in n8n
|
||||
|
||||
Be aware of the following:
|
||||
|
||||
* In a workflow, n8n converts dates and times to strings between nodes. Keep this in mind when doing arithmetic on dates and times from other nodes.
|
||||
* With vanilla JavaScript, you can convert a string to a date with `new Date('2019-06-23')`. In Luxon, you must use a function explicitly stating the format, such as `DateTime.fromISO('2019-06-23')` or `DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")`.
|
||||
|
||||
## Common tasks
|
||||
|
||||
This section provides examples for some common operations. More examples, and detailed guidance, are available in [Luxon's own documentation](https://moment.github.io/luxon/#/?id=luxon){:target="_blank" .external-link}.
|
||||
|
||||
### Convert date string to Luxon
|
||||
|
||||
You can convert date strings and other date formats to a Luxon DateTime object. You can convert from standard formats and from arbitrary strings.
|
||||
|
||||
!!! note "A difference between Luxon DateTime and JavaScript Date"
|
||||
With vanilla JavaScript, you can convert a string to a date with `new Date('2019-06-23')`. In Luxon, you must use a function explicitly stating the format, such as `DateTime.fromISO('2019-06-23')` or `DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")`.
|
||||
|
||||
#### If you have a date in a supported standard technical format:
|
||||
|
||||
Most dates use `fromISO()`. This creates a Luxon DateTime from an ISO 8601 string. For example:
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{DateTime.fromISO('2019-06-23T00:00:00.00')}}
|
||||
```
|
||||
|
||||
=== "Code node"
|
||||
|
||||
```js
|
||||
let luxonDateTime = DateTime.fromISO('2019-06-23T00:00:00.00')'
|
||||
```
|
||||
Luxon's API documentation has more information on [fromISO](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso){:target="_blank" .external-link}.
|
||||
|
||||
Luxon provides functions to handle conversions for a range of formats. Refer to Luxon's guide to [Parsing technical formats](https://moment.github.io/luxon/#/parsing?id=parsing-technical-formats) for details.
|
||||
|
||||
#### If you have a date as a string that doesn't use a standard format:
|
||||
|
||||
Use Luxon's [Ad-hoc parsing](https://moment.github.io/luxon/#/parsing?id=ad-hoc-parsing){:target="_blank" .external-link}. To do this, use the `fromFormat()` function, providing the string and a set of [tokens](https://moment.github.io/luxon/#/parsing?id=table-of-tokens){:target="_blank" .external-link} that describe the format.
|
||||
|
||||
For example, you have n8n's founding date, 23rd June 2019, formatted as '23-06-2019'. You want to turn this into a Luxon object:
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")}}
|
||||
```
|
||||
|
||||
=== "Code node"
|
||||
|
||||
```js
|
||||
let newFormat = DateTime.fromFormat("23-06-2019", "dd-MM-yyyy")
|
||||
```
|
||||
|
||||
When using ad-hoc parsing, note Luxon's warning about [Limitations](https://moment.github.io/luxon/#/parsing?id=limitations){:target="_blank" .external-link}. If you see unexpected results, try their [Debugging](https://moment.github.io/luxon/#/parsing?id=debugging){:target="_blank" .external-link} guide.
|
||||
|
||||
### Get n days from today
|
||||
|
||||
Get a number of days before or after today.
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
For example, you want to set a field to always show the date seven days before the current date.
|
||||
|
||||
In the expressions editor, enter:
|
||||
|
||||
|
||||
``` js
|
||||
{{$today.minus({days: 7})}}
|
||||
```
|
||||
|
||||
On the 23rd June 2019, this returns `[Object: "2019-06-16T00:00:00.000+00:00"]`.
|
||||
|
||||
This example uses n8n's custom variable `$today` for convenience. It's the equivalent of `DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 }).minus({days: 7})`.
|
||||
|
||||
=== "Code node"
|
||||
|
||||
For example, you want a variable containing the date seven days before the current date.
|
||||
|
||||
In the code editor, enter:
|
||||
|
||||
``` js
|
||||
let sevenDaysAgo = $today.minus({days: 7})
|
||||
```
|
||||
|
||||
On the 23rd June 2019, this returns `[Object: "2019-06-16T00:00:00.000+00:00"]`.
|
||||
|
||||
This example uses n8n's custom variable `$today` for convenience. It's the equivalent of `DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 }).minus({days: 7})`.
|
||||
|
||||
For more detailed information and examples, refer to:
|
||||
|
||||
* Luxon's [guide to math](https://moment.github.io/luxon/#/math)
|
||||
* Their API documentation on [DateTime plus](https://moment.github.io/luxon/api-docs/index.html#datetimeplus) and [DateTime minus](https://moment.github.io/luxon/api-docs/index.html#datetimeminus)
|
||||
|
||||
### Create human-readable dates
|
||||
|
||||
In [Get n days from today](#get-n-days-from-today), the example gets the date seven days before the current date, and returns it as `[Object: "yyyy-mm-dd-T00:00:00.000+00:00"]` (for expressions) or `yyyy-mm-dd-T00:00:00.000+00:00` (in the Code node). To make this more readable, you can use Luxon's formatting functions.
|
||||
|
||||
For example, you want the field containing the date to be formatted as DD/MM/YYYY, so that on the 23rd June 2019, it returns 23/06/2019.
|
||||
|
||||
This expression gets the date seven days before today, and converts it to the DD/MM/YYYY format.
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{$today.minus({days: 7}).toLocaleString()}}
|
||||
```
|
||||
|
||||
=== "Code node"
|
||||
|
||||
```js
|
||||
let readableSevenDaysAgo = $today.minus({days: 7}).toLocaleString()
|
||||
```
|
||||
|
||||
You can alter the format. For example:
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{$today.minus({days: 7}).toLocaleString({month: 'long', day: 'numeric', year: 'numeric'})}}
|
||||
```
|
||||
|
||||
On 23rd June 2019, this returns "16 June 2019".
|
||||
|
||||
=== "Code node"
|
||||
|
||||
```js
|
||||
let readableSevenDaysAgo = $today.minus({days: 7}).toLocaleString({month: 'long', day: 'numeric', year: 'numeric'})
|
||||
```
|
||||
|
||||
On 23rd June 2019, this returns "16 June 2019".
|
||||
|
||||
Refer to Luxon's guide on [toLocaleString (strings for humans)](https://moment.github.io/luxon/#/formatting?id=tolocalestring-strings-for-humans){:target="_blank" .external-link} for more information.
|
||||
|
||||
|
||||
### Get the time between two dates
|
||||
|
||||
To get the time between two dates, use Luxon's diffs feature. This subtracts one date from another and returns a duration.
|
||||
|
||||
For example, get the number of months between two dates:
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{DateTime.fromISO('2019-06-23').diff(DateTime.fromISO('2019-05-23'), 'months').toObject()}}
|
||||
```
|
||||
|
||||
This returns `[Object: {"months":1}]`.
|
||||
|
||||
=== "Code node"
|
||||
|
||||
```js
|
||||
let monthsBetweenDates = DateTime.fromISO('2019-06-23').diff(DateTime.fromISO('2019-05-23'), 'months').toObject()
|
||||
```
|
||||
|
||||
This returns `{"months":1}`.
|
||||
|
||||
Refer to Luxon's [Diffs](https://moment.github.io/luxon/#/math?id=diffs){:target=_blank .external-link} for more information.
|
||||
|
||||
### A longer example: How many days to Christmas?
|
||||
|
||||
This example brings together several Luxon features, uses JMESPath, and does some basic string manipulation.
|
||||
|
||||
The scenario: you want a countdown to 25th December. Every day, it should tell you the number of days remaining to Christmas. You don't want to update it for next year - it needs to seamlessly work for every year.
|
||||
|
||||
=== "Expressions"
|
||||
|
||||
```js
|
||||
{{"There are " + $today.diff(DateTime.fromISO($today.year + '-12-25'), 'days').toObject().days.toString().substring(1) + " days to Christmas!"}}
|
||||
```
|
||||
|
||||
This outputs `"There are <number of days> days to Christmas!"`. For example, on 9th March, it outputs "There are 291 days to Christmas!".
|
||||
|
||||
A detailed explanation of what the expression does:
|
||||
|
||||
* `{{`: indicates the start of the expression.
|
||||
* `"There are "`: a string.
|
||||
* `+`: used to join two strings.
|
||||
* `$today.diff()`: This is similar to the example in [Get the time between two dates](#get-the-time-between-two-dates), but it uses n8n's custom `$today` variable.
|
||||
* `DateTime.fromISO($today.year + '-12-25'), 'days'`: this part gets the current year using `$today.year`, turns it into an ISO string along with the month and date, and then takes the whole ISO string and converts it to a Luxon DateTime data structure. It also tells Luxon that you want the duration in days.
|
||||
* `toObject()` turns the result of diff() into a more usable object. At this point, the expression returns `[Object: {"days":-<number-of-days>}]`. For example, on 9th March, `[Object: {"days":-291}]`.
|
||||
* `.days` uses JMESPath syntax to retrieve just the number of days from the object. For more information on using JMESPath with n8n, refer to our [JMESpath](/code/jmespath/) documentation. This gives you the number of days to Christmas, as a negative number.
|
||||
* `.toString().substring(1)` turns the number into a string and removes the `-`.
|
||||
* `+ " days to Christmas!"`: another string, with a `+` to join it to the previous string.
|
||||
* `}}`: indicates the end of the expression.
|
||||
|
||||
=== "Code node"
|
||||
|
||||
```js
|
||||
let daysToChristmas = "There are " + $today.diff(DateTime.fromISO($today.year + '-12-25'), 'days').toObject().days.toString().substring(1) + " days to Christmas!";
|
||||
```
|
||||
|
||||
This outputs `"There are <number of days> days to Christmas!"`. For example, on 9th March, it outputs "There are 291 days to Christmas!".
|
||||
|
||||
A detailed explanation of what the code does:
|
||||
|
||||
* `"There are "`: a string.
|
||||
* `+`: used to join two strings.
|
||||
* `$today.diff()`: This is similar to the example in [Get the time between two dates](#get-the-time-between-two-dates), but it uses n8n's custom `$today` variable.
|
||||
* `DateTime.fromISO($today.year + '-12-25'), 'days'`: this part gets the current year using `$today.year`, turns it into an ISO string along with the month and date, and then takes the whole ISO string and converts it to a Luxon DateTime data structure. It also tells Luxon that you want the duration in days.
|
||||
* `toObject()` turns the result of diff() into a more usable object. At this point, the expression returns `[Object: {"days":-<number-of-days>}]`. For example, on 9th March, `[Object: {"days":-291}]`.
|
||||
* `.days` uses JMESPath syntax to retrieve just the number of days from the object. For more information on using JMESPath with n8n, refer to our [JMESpath](/code/jmespath/) documentation. This gives you the number of days to Christmas, as a negative number.
|
||||
* `.toString().substring(1)` turns the number into a string and removes the `-`.
|
||||
* `+ " days to Christmas!"`: another string, with a `+` to join it to the previous string.
|
||||
@@ -12,7 +12,7 @@ Expressions allow you to set node parameters dynamically based on data from:
|
||||
|
||||
You can execute JavaScript within an expression.
|
||||
|
||||
n8n uses the [riot-tmpl](https://github.com/riot/tmpl) templating language, and extends it with [custom methods and variables](/code-examples/methods-variables-reference/) and [data transformation functions](/code-examples/expressions/data-transformation-functions/) that help with common tasks, such as retrieving data from other nodes, or accessing metadata.
|
||||
n8n uses the [riot-tmpl](https://github.com/riot/tmpl) templating language, and extends it with [custom methods and variables](/code/builtin/) and [data transformation functions](/code/builtin/data-transformation-functions/) that help with common tasks, such as retrieving data from other nodes, or accessing metadata.
|
||||
|
||||
n8n supports two libraries:
|
||||
|
||||
@@ -135,7 +135,7 @@ In a Code node, create an array of objects named `myContacts` that contains the
|
||||
|
||||
## Referencing node data with the Code node
|
||||
|
||||
Just like you can use [expressions](/code-examples/expressions/) to reference data from other nodes, you can also use some [methods and variables](/code-examples/methods-variables-reference/) in the Code node.
|
||||
Just like you can use [expressions](/code-examples/expressions/) to reference data from other nodes, you can also use some [methods and variables](/code/builtin/) in the Code node.
|
||||
|
||||
### Exercise
|
||||
|
||||
|
||||
@@ -43,12 +43,12 @@ You can trigger a workflow based on changes to a local file using the [Local Fil
|
||||
|
||||
### Code
|
||||
|
||||
You can use the [Code node](/code-examples/javascript-functions/code-node/) to manipulate binary data in your workflows.
|
||||
You can use the [Code node](/code/code-node/) to manipulate binary data in your workflows.
|
||||
|
||||
Some examples:
|
||||
|
||||
* [Get the binary data buffer](/code-examples/javascript-functions/get-binary-data-buffer/): get the binary data available in your workflow.
|
||||
* [Split binary data into individual items](/code-examples/javascript-functions/split-binary-file-data/): if you receive more than one binary file from a node, you can split the binary data into individual items.
|
||||
* [Get the binary data buffer](/code/cookbook/code-node/get-binary-data-buffer/): get the binary data available in your workflow.
|
||||
* [Split binary data into individual items](/code/cookbook/code-node/split-binary-file-data/): if you receive more than one binary file from a node, you can split the binary data into individual items.
|
||||
|
||||
## Configure binary data mode when self-hosting
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ View [example workflows and related content](https://n8n.io/integrations/html/){
|
||||
|
||||
## Generate HTML template
|
||||
|
||||
Create an HTML template. This allows you to take data from your workflow and output it as HTML. You can use [Expressions](/code-examples/) in the template, including n8n's [Built-in methods and variables](/code-examples/methods-variables-reference/)
|
||||
Create an HTML template. This allows you to take data from your workflow and output it as HTML. You can use [Expressions](/code-examples/) in the template, including n8n's [Built-in methods and variables](/code/builtin/)
|
||||
|
||||
You can include:
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ This release contains new features and bug fixes.
|
||||
|
||||
This release introduces limited support for using AI to generate code in the Code node. Initially this feature is only available on Cloud, and will gradually be rolled out, starting with about 20% of users.
|
||||
|
||||
Learn how to use the feature, including guidance on writing prompts, in [Generate code with ChatGPT](/code-examples/ai-code/).
|
||||
Learn how to use the feature, including guidance on writing prompts, in [Generate code with ChatGPT](/code/ai-code/).
|
||||
|
||||
</div>
|
||||
|
||||
@@ -420,7 +420,7 @@ For full details, refer to the [n8n v1.0 migration guide](/1-0-migration-checkli
|
||||
|
||||
#### Python support
|
||||
|
||||
Although JavaScript remains the default language, you can now also select Python as an option in the [Code node](/code-examples/javascript-functions/code-node/) and even make use of [many Python modules](https://pyodide.org/en/stable/usage/packages-in-pyodide.html#packages-in-pyodide){:target=_blank .external link}. Note that Python is unavailable in Code nodes added to a workflow before v1.0.
|
||||
Although JavaScript remains the default language, you can now also select Python as an option in the [Code node](/code/code-node/) and even make use of [many Python modules](https://pyodide.org/en/stable/usage/packages-in-pyodide.html#packages-in-pyodide){:target=_blank .external link}. Note that Python is unavailable in Code nodes added to a workflow before v1.0.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1660,7 +1660,7 @@ This release includes an overhaul of the Slack node, adding new operations and a
|
||||
View the [commits](https://github.com/n8n-io/n8n/compare/n8n@0.213.0...n8n@0.214.0){:target=_blank .external-link} for this version.<br />
|
||||
**Release date:** 2023-02-03
|
||||
|
||||
This release contains new features, node enhancements, and bug fixes. The expressions editor now supports autocomplete for some [built in data transformation functions](/code-examples/expressions/data-transformation-functions/). The new features also include two of interest to node builders: a way to allow users to drag and drop data keys, and the new HTML editor component.
|
||||
This release contains new features, node enhancements, and bug fixes. The expressions editor now supports autocomplete for some [built in data transformation functions](/code/builtin/data-transformation-functions/). The new features also include two of interest to node builders: a way to allow users to drag and drop data keys, and the new HTML editor component.
|
||||
|
||||
!!! warning "Breaking changes"
|
||||
Please note that this version contains a breaking change to Luxon. You can read more about it [here](https://github.com/n8n-io/n8n/blob/master/packages/cli/BREAKING-CHANGES.md#02140){:target=_blank .external-link}.
|
||||
@@ -1671,7 +1671,7 @@ This release contains new features, node enhancements, and bug fixes. The expres
|
||||
|
||||
#### Autocomplete in the Extension editor
|
||||
|
||||
[Data transformation functions](/code-examples/expressions/data-transformation-functions/) now have autocomplete support in the Expression editor.
|
||||
[Data transformation functions](/code/builtin/data-transformation-functions/) now have autocomplete support in the Expression editor.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -2887,7 +2887,7 @@ Introducing improved support for item linking (paired items). Item linking is a
|
||||
|
||||
#### Overhauled built-in variables
|
||||
|
||||
n8n's [built-in methods and variables](/code-examples/methods-variables-reference/) have been overhauled, introducing new variables, and providing greater consistency in behavior and naming.
|
||||
n8n's [built-in methods and variables](/code/builtin/) have been overhauled, introducing new variables, and providing greater consistency in behavior and naming.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -4137,7 +4137,7 @@ View the [commits](https://github.com/n8n-io/n8n/compare/n8n@0.171.1...n8n@0.172
|
||||
|
||||
### Bug fixes
|
||||
|
||||
**core**: Luxon now applies the correct timezone. Refer to [Luxon](/code-examples/expressions/luxon/) for more information.<br>
|
||||
**core**: Luxon now applies the correct timezone. Refer to [Luxon](/code/luxon/) for more information.<br>
|
||||
**core**: fixed an issue with localization that was preventing i18n files from loading.<br>
|
||||
[Action Network Node:](/integrations/builtin/app-nodes/n8n-nodes-base.actionnetwork/) Fix a pagination issue and add credentials test.
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ The [NASA node](/integrations/builtin/app-nodes/n8n-nodes-base.nasa/) allows you
|
||||
This generates a date in the correct format, seven days before the current date.
|
||||
|
||||
!!! note "Date and time in n8n"
|
||||
n8n uses Luxon to work with date and time, and also provides two variables for convenience: `$now` and `$today`. For more information, refer to [Expressions > Luxon](/code-examples/expressions/luxon/).
|
||||
n8n uses Luxon to work with date and time, and also provides two variables for convenience: `$now` and `$today`. For more information, refer to [Expressions > Luxon](/code/luxon/).
|
||||
|
||||
7. Close the **Edit Expression** modal to return to the NASA node.
|
||||
8. You can now check that the node is working and returning the expected date: select **Execute node** to run the node manually. n8n calls the NASA API and displays details of solar flares in the past seven days in the **OUTPUT** section.
|
||||
|
||||
73
mkdocs.yml
73
mkdocs.yml
@@ -173,42 +173,6 @@ nav:
|
||||
- Data pinning: data/data-pinning.md
|
||||
- Data editing: data/data-editing.md
|
||||
- Binary data: data/binary-data.md
|
||||
- Code in n8n:
|
||||
- code-examples/index.md
|
||||
- Built in methods and variables reference: code-examples/methods-variables-reference.md
|
||||
- Built-in methods and variables examples:
|
||||
- code-examples/methods-variables-examples/index.md
|
||||
- evaluateExpression: code-examples/methods-variables-examples/evaluate-expression.md
|
||||
- execution: code-examples/methods-variables-examples/execution.md
|
||||
- getWorkflowStaticData: code-examples/methods-variables-examples/get-workflow-static-data.md
|
||||
- (node-name).item: code-examples/methods-variables-examples/node.md
|
||||
- (node-name).all: code-examples/methods-variables-examples/all.md
|
||||
- runIndex: code-examples/methods-variables-examples/run-index.md
|
||||
- vars: code-examples/methods-variables-examples/vars.md
|
||||
- workflow: code-examples/methods-variables-examples/workflow.md
|
||||
- Expressions:
|
||||
- code-examples/expressions/index.md
|
||||
- Understand expressions: code-examples/expressions/understand-expressions.md
|
||||
- Date and time with Luxon: code-examples/expressions/luxon.md
|
||||
- JSON with JMESPath: code-examples/expressions/jmespath.md
|
||||
- Check incoming data: code-examples/expressions/check-incoming-data.md
|
||||
- Data transformation functions:
|
||||
- code-examples/expressions/data-transformation-functions/index.md
|
||||
- Arrays: code-examples/expressions/data-transformation-functions/arrays.md
|
||||
- Dates: code-examples/expressions/data-transformation-functions/dates.md
|
||||
- Numbers: code-examples/expressions/data-transformation-functions/numbers.md
|
||||
- Objects: code-examples/expressions/data-transformation-functions/objects.md
|
||||
- Strings: code-examples/expressions/data-transformation-functions/strings.md
|
||||
- JavaScript:
|
||||
- code-examples/javascript-functions/index.md
|
||||
- Code node: code-examples/javascript-functions/code-node.md
|
||||
- Date and time with Luxon: code-examples/javascript-functions/luxon.md
|
||||
- JSON with JMESPath: code-examples/javascript-functions/jmespath.md
|
||||
- Get number of items returned by last node: code-examples/javascript-functions/number-items-last-node.md
|
||||
- Split binary file data into individual items: code-examples/javascript-functions/split-binary-file-data.md
|
||||
- Get the binary data buffer: code-examples/javascript-functions/get-binary-data-buffer.md
|
||||
- Using console.log: code-examples/javascript-functions/console-log.md
|
||||
- Generate code with ChatGPT: code-examples/ai-code.md
|
||||
- User management:
|
||||
- user-management/index.md
|
||||
- Cloud setup: user-management/cloud-setup.md
|
||||
@@ -609,6 +573,43 @@ nav:
|
||||
- hosting/architecture/index.md
|
||||
- Database structure: hosting/architecture/database-structure.md
|
||||
- CLI commands: hosting/cli-commands.md
|
||||
- Coding in n8n:
|
||||
- code/index.md
|
||||
- Understand expressions: code/understand-expressions.md
|
||||
- Code node: code/code-node.md
|
||||
- Built in methods and variables:
|
||||
- code/builtin/index.md
|
||||
- Data transformation functions:
|
||||
- code-examples/expressions/data-transformation-functions/index.md
|
||||
- Arrays: code-examples/expressions/data-transformation-functions/arrays.md
|
||||
- Dates: code-examples/expressions/data-transformation-functions/dates.md
|
||||
- Numbers: code-examples/expressions/data-transformation-functions/numbers.md
|
||||
- Objects: code-examples/expressions/data-transformation-functions/objects.md
|
||||
- Strings: code-examples/expressions/data-transformation-functions/strings.md
|
||||
- Handling dates: code/luxon.md
|
||||
- Query JSON with JMESPath: code/jmespath.md
|
||||
- Generate code with ChatGPT: code/ai-code.md
|
||||
- Cookbook:
|
||||
- code/cookbook/index.md
|
||||
- Built-in methods and variables examples:
|
||||
- code/cookbook/builtin/index.md
|
||||
- evaluateExpression: code-examples/cookbook/builtin/evaluate-expression.md
|
||||
- execution: code-examples/cookbook/builtin/execution.md
|
||||
- getWorkflowStaticData: code-examples/cookbook/builtin/get-workflow-static-data.md
|
||||
- (node-name).item: code-examples/cookbook/builtin/node.md
|
||||
- (node-name).all: code-examples/cookbook/builtin/all.md
|
||||
- runIndex: code-examples/cookbook/builtin/run-index.md
|
||||
- vars: code-examples/cookbook/builtin/vars.md
|
||||
- workflow: code-examples/cookbook/builtin/workflow.md
|
||||
- Expressions:
|
||||
- code/cookbook/expressions/index.md
|
||||
- Check incoming data: code/cookbook/expressions/check-incoming-data.md
|
||||
- Code node:
|
||||
- code/cookbook/code-node/index.md
|
||||
- Get number of items returned by last node: code/cookbook/code-node/number-items-last-node.md
|
||||
- Split binary file data into individual items: code/cookbook/code-node/split-binary-file-data.md
|
||||
- Get the binary data buffer: code/cookbook/code-node/get-binary-data-buffer.md
|
||||
- Using console.log: code/cookbook/code-node/console-log.md
|
||||
- API:
|
||||
- api/index.md
|
||||
- Authentication: api/authentication.md
|
||||
|
||||
Reference in New Issue
Block a user