Vectrune documentationAlpha referenceLearning site ↗

Native collection methods

Collection methods available on arrays in native request contexts.

array.find

result = <array>.find <left> <comparison> <right>

Find the first element satisfying a native comparison.

Runtime: Native / server

Returns / effects

First matching JSON value, or null. it refers to the current element.

Errors / edge cases

The native method requires a supported comparison rather than an arbitrary callback.

Example
item = items.find it.id == "1.10"

Implementation: src/builtins.rs

array.find-index

index = <array>.find-index <left> <comparison> <right>

Find the index of the first matching native array element.

Runtime: Native / server

Returns / effects

Zero-based index, or -1 when no match is found.

Example
index = items.find-index it.id == "1.10"

Implementation: src/builtins.rs

array.max

result = <array>.max [it.<field>]

Compute the maximum numeric element or selected object field.

Runtime: Native / server

Returns / effects

Maximum number; an empty array returns 0. Non-numeric selected values contribute 0.

Example
last_id = users.max it.id

Implementation: src/builtins.rs

array.remove

<array>.remove <index>

Remove one element by zero-based index.

Runtime: Native / server

Returns / effects

Mutates the context array. Negative and out-of-range indices are ignored.

Errors / edge cases

Missing index is a builtin error.

Example
users.remove index

Implementation: src/builtins.rs