Skip to main content

JS Function

A JavaScript function any expression can call by name, run by DuckDB per row. For logic the expression language has no words for; it returns a number, or an array of width numbers. Prefer an expression where one will do: DuckDB runs JS some 20 times slower than SQL.

Syntax​

{ "id": "n1", "op": "js-function", "name": "js-function", "x": 0, "y": 0, "params": {} }

A parameter is set in params (leave out the ones at their default), driven by an edge to par:width, or read elsewhere as ch('js-function/width').

Inputs​

This operator has no input ports.

Parameters​

ParameterKindDefaultChoices
namestring"fn"
paramsstring"x"
widthint1
bodycode"return x"

Outputs​

This operator has no outputs.

Details​

  • Category: Rows
  • Operator: js-function

Older projects​

Projects saved before documents used operator classes. These convert to js-function when they open: AccessorOp.