Registry / database / slimsql

slimsql

JSON →
library1.0.15jsnpmunverified

SlimSQL is a lightweight in-memory SQL query engine for JavaScript, version 1.0.15. It allows running SQL queries directly on JavaScript arrays by registering them as virtual tables. It supports SELECT, JOINs, window functions (e.g., RANK), WHERE, GROUP BY, ORDER BY, and aggregation. Different from libraries like alasql, SlimSQL is minimal (43KB gzipped) with no dependencies, TypeScript types included, and focuses on basic SQL for data exploration. Release cadence is moderate; last update May 2023. Works in Node.js and browsers (ESM/CJS/UMD).

npm install slimsql
INSTALL
IMPORT
SIG · SLIMSQL
S
slimsql
databasejavascriptv1.0.15
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SQLSession
import { SQLSession } from 'slimsql'
const { SQLSession } = require('slimsql')
ESM default; CJS require works but named import might fail in some bundlers; use default import for CJS.
SQLSession (default import)
import SQLSession from 'slimsql'
const slimsql = require('slimsql')
Default export is the SQLSession class. CommonJS require gives an object with 'default' property in ESM interop.
type TableRow or QueryResult
import type { TableRow, QueryResult } from 'slimsql'
const { TableRow } = require('slimsql')
Types are exported but not runtime objects; only for TypeScript.

Demonstrates creating a SQLSession, registering a JavaScript array as a table, and querying with a basic SELECT with WHERE clause.

import { SQLSession } from 'slimsql'; const data = [ { id: 1, name: 'Alice', score: 10 }, { id: 2, name: 'Bob', score: 20 }, ]; const session = new SQLSession(); session.registTableView(data, 'users'); const result = session.sql('SELECT name, score FROM users WHERE score > 15'); console.table(result.data); // Output: [{ name: 'Bob', score: 20 }]
Debug
Known issues
gotchaTable names must be strings; registration does not validate uniqueness. Overwriting an existing table silently replaces it.
fix
Ensure unique table names; use 'existsTableView' method to check.
affects: >=1.0.0
gotchaWindow functions (RANK, DENSE_RANK, ROW_NUMBER) are supported but only PARTITION BY and ORDER BY; no frame clause (ROWS/RANGE).
fix
Use only supported SQL features; read docs for limitations.
affects: >=1.0.0
gotchaNULL handling may differ from SQL standard: comparisons like NULL = NULL return false, not NULL; IS NULL works correctly.
fix
Use IS NULL / IS NOT NULL explicitly.
affects: >=1.0.0
gotchaThe 'sql' method is synchronous; does not support async/await. Long queries block the main thread.
fix
For large datasets, consider chunking or offloading to Web Workers (browser).
affects: >=1.0.0
Errors
Common errors & fixes
Cannot use import statement outside a module
Using ESM import in a CommonJS Node.js project without 'type':'module' in package.json.
fix
Add 'type':'module' to package.json or use require('slimsql') with CJS.
require is not defined
Using require in an ESM module; node expects import.
fix
Use import { SQLSession } from 'slimsql' instead of require.
TypeError: session.registTableView is not a function
Typo: 'registTableView' is misspelled 'register' or 'registerTableView'.
fix
Method name is 'registTableView' (no 'er' after 'regist'). Use exact string: session.registTableView(...).
Upgrade
Version history
1.0.15latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Meta
2
Resources
slimsql — npm install slimsql · libregistry