Limit
Keeps at most a set number of items from the start or the end of a list, optionally skipping some first.
Parameters
| Name | Required | Default | Description |
|---|---|---|---|
Items (input) | Yes | — | The array to limit, e.g. {{ $nodes['Sort'].items }}. |
Max items (maxItems) | Yes | 10 | How many items to keep. Negative values count as 0. |
Keep (keep) | No | First items | first keeps items from the start; last keeps items from the end. |
Skip (offset) | No | 0 | Items to skip before counting — from the start with First items, from the end with Last items. |
Ports
| Port | Description |
|---|---|
main (input) | The step(s) Limit runs after. |
output | { items, count, total } |
Output
{
"items": [ { "id": 11 }, { "id": 12 }, { "id": 13 } ],
"count": 3,
"total": 40
}
count is how many items were kept; total is how many came in.
Example
Page through a list 10 at a time — the second page:
- Items:
{{ $nodes['Get Tickets'].items }} - Max items:
10 - Keep: First items
- Skip:
10
Or take the 5 newest entries from a list sorted oldest first: Keep = Last items, Max items = 5.
Notes
- Items must resolve to an array (a single value is a one-item list; an empty value an empty list). Stored files must be parsed first.
- Pair with Sort for "top N" lists.