loladotdev / js_eval_ext

πŸ‡ SQLite3 JavaScript Eval Extension

Home Page:https://lola.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQLite3 JavaScript Eval Extension

This SQLite3 extension allows you to evaluate JavaScript expressions using the Duktape library.

Prerequisites

  • CMake >= 3.16

Building

To build the extension, follow these steps:

  1. Create a build directory:
    mkdir build
    cd build
  2. Generate the build files using CMake:
    cmake ..
  3. Build the extension:
    make

This will create the libeval_js.so shared library in the build directory.

Usage

  1. Load the extension in SQLite3:

    SELECT load_extension('/path/to/libjs_eval_ext.so', 'sqlite3_js_eval_init');

    Replace /path/to/libeval_js.so with the actual path to the built libeval_js.so file.

  2. Use the eval_js function to evaluate JavaScript expressions:

    SELECT eval_js('a * (b + c)', 'a', 2, 'b', 3, 'c', 4) AS result;

    This will evaluate the JavaScript expression a * (b + c) with the provided key-value pairs as variables (a = 2, b = 3, c = 4) and return the result (14).

Running Tests

To run the tests, execute the following command in the build directory:

ctest

This will run the test suite and display the results.

About

πŸ‡ SQLite3 JavaScript Eval Extension

https://lola.dev


Languages

Language:C 100.0%Language:CMake 0.0%