array-functions.md

March 28, 2026 ยท View on GitHub

Scope

Array filter functions available through the core query engine.

Source of truth: src/packages/core/src/query-engine/functions/array-functions.ts

Function List (19)

FunctionSignatureDescriptionExample
lengthlength(arrayValue)Array length.[1,2,3] | length -> 3
sizesize(value)Size of array/object.{a:1,b:2} | size -> 2
firstfirst(arrayValue)First element.[10,20] | first -> 10
lastlast(arrayValue)Last element.[10,20] | last -> 20
nthnth(arrayValue, index)Element at index.["a","b","c"] | nth(1) -> "b"
reversereverse(arrayValue)Reverse array copy.[1,2,3] | reverse -> [3,2,1]
sortsort(arrayValue, key?)Sort values or object list by key.[{n:2},{n:1}] | sort("n") -> [{n:1},{n:2}]
uniqueunique(arrayValue)Remove duplicates.[1,1,2] | unique -> [1,2]
flattenflatten(arrayValue, depth?)Flatten nested arrays.[[1],[2]] | flatten -> [1,2]
sliceslice(arrayValue, start, end?)Array slice.[1,2,3,4] | slice(1,3) -> [2,3]
concatconcat(arrayValue, ...arrays)Concatenate one or more arrays.[1,2] | concat([3,4], [5]) -> [1,2,3,4,5]
joinjoin(arrayValue, separator)Join to string.["a","b"] | join("-") -> "a-b"
filterfilter(arrayValue, predicate)Filter with function or expression.[1,2,3] | filter("> 1") -> [2,3]
mapmap(arrayValue, fn)Map with function or property key.[{n:1}] | map("n") -> [1]
findfind(arrayValue, condition)First matching item.[1,2,3] | find("> 1") -> 2
includesincludes(arrayValue, item)Membership check.[1,2,3] | includes(2) -> true
indexOfindexOf(arrayValue, item)Index lookup.[1,2,3] | indexOf(2) -> 1

| reduce | reduce(arrayValue) | Returns input unchanged. | [1,2,3] \| reduce -> [1,2,3] | | where | where(arrayValue, key) | Keep entries with truthy key. | [{a:true},{a:false}] \| where("a") -> [{a:true}] |

Notes

  • Expression forms in filter and find support simple scalar and field comparisons.
  • sort and reverse return a copied array and do not mutate input.
  • where is a convenience alias for truthy-key filtering.
  • reduce currently does not accept a reducer callback and is documented to match the current implementation behavior.