Skip to content
Search

SQLite-JS

lastmod 2025-06-09created 2025-06-091 edits

Create custom SQLite functions in JavaScript. Extend your database with scalars, aggregates, window functions, and collations directly in JavaScript.

An extension that adds JavaScript capabilities to SQLite

Features

  • An extension tool for implementing user-defined functions, aggregates, window functions, collations, etc. in JavaScript in a SQLite DB
    • Logic that is hard to express in SQL can be registered and run directly as JavaScript code
  • Goes beyond the limits of plain SQL: text processing, math operations, statistics, special aggregates, natural sorting, etc. can be implemented simply in JavaScript for various data processing scenarios
  • Usable right away just by loading the extension module; js_eval runs JavaScript code directly within queries, and user-defined function sync makes it behave the same in distributed cluster environments
  • Function, aggregate, window, and collation logic can be created/modified dynamically from SQL, making it very effective for complex business logic, data analysis, and statistical processing
  • Advanced processing impossible with plain SQLite, such as time zone, locale, and custom sorting, advanced statistics, and real-time analysis, becomes possible through the JavaScript ecosystem

Key functions

  • Scalar Functions: Return one result per row, used for data processing/calculation (e.g., calculating age from a birthday, extracting an email domain)
  • Aggregate Functions: Process multiple rows and return a single value (e.g., custom aggregates such as standard deviation, median)
  • Window Functions: Can access the whole data set, support complex window operations such as sliding/cumulative statistics, moving averages
  • Collation Sequences: Implement custom sorting algorithms in JavaScript; locale, natural-language, case-insensitive sorting, etc. are possible
  • JavaScript Evaluation: Runs JavaScript code instantly within SQL queries, for arbitrary operations, data transformation, etc.
  • Distributed environment sync: Integrated with sqlite-sync, created JS functions are automatically synced across both cluster and offline environments

See also

Favorite site

author Zer0 sitemap