quickjs

DuckDB-QuickJS-Laufzeitumgebung

Maintainer: lmangani

Installation und Laden

INSTALL quickjs FROM community;
LOAD quickjs;

Beispiel

-- Quack JS with QuickJS
-- Scalar
D SELECT quickjs('2+2');
┌────────────────┐
│ quickjs('2+2') │
varchar
├────────────────┤
4
└────────────────┘
-- Scalar Eval
D SELECT quickjs_eval('(a, b) => a + b', 5, 3);
┌───────────────────────────────────────┐
│ quickjs_eval('(a, b) => a + b', 5, 3) │
json
├───────────────────────────────────────┤
8
└───────────────────────────────────────┘
-- Table Eval
D SELECT * FROM quickjs('parsed_arg0.map(x => x * arg1)', '[1, 2, 3, 4, 5]', 3);
┌────────┐
│ result │
json
├────────┤
3
6
9
12
15
└────────┘

Über quickjs

QuickJS-DuckDB-Erweiterung

Diese Erweiterung stellt eine eingebettete QuickJS-NG-Engine für DuckDB bereit. Sie ermöglicht die Ausführung von JavaScript-Code direkt in Ihren SQL-Abfragen.

QuickJS-NG ist eine kleine, schnelle und einbettbare JavaScript-Engine, die moderne JavaScript-Funktionen einschließlich ES2020 unterstützt.

Diese Erweiterung ist experimentell und potenziell instabil. Verwenden Sie sie nicht in der Produktion.

Hinzugefügte Funktionen

function_name function_type description comment examples
quickjs scalar Execute JavaScript code and return the result as a string NULL [quickjs(‘1 + 2’), quickjs(‘“hello”.toUpperCase()’)]
quickjs table Execute JavaScript code that returns an array, with each element becoming a row NULL [SELECT * FROM quickjs(‘[1, 2, 3].map(x => x * 2)’)]
quickjs_eval scalar Execute a JavaScript function with the provided arguments and return the result as JSON NULL [quickjs_eval(‘(a, b) => a + b’, 1, 2), quickjs_eval(‘(x) => x * 2’, 21)]

Überladene Funktionen

Diese Erweiterung fügt keine Funktionsüberladungen hinzu.

Hinzugefügte Typen

Diese Erweiterung fügt keine Typen hinzu.

Hinzugefügte Einstellungen

Diese Erweiterung fügt keine Einstellungen hinzu.