Registry / database / sqlweb

sqlweb

JSON →
library1.6.2jsnpmunverified

SqlWeb is an extension of JsStore that allows using SQL queries for IndexedDB operations. Current stable version is 1.6.2. It provides a familiar SQL interface on top of JsStore's SQL-like query builder. The library is maintained alongside JsStore but has a distinct release cadence. Key differentiator: it enables direct SQL syntax (e.g., SELECT * FROM) instead of JsStore's JSON-based query objects. Requires JsStore >=4.0.3 as a peer dependency. Ships TypeScript definitions. Suitable for developers migrating from WebSQL or those preferring SQL syntax over programmatic APIs.

npm install sqlweb
INSTALL
IMPORT
SIG · SQLWEB
S
sqlweb
databasejavascriptv1.6.2
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.

default
import SqlWeb from 'sqlweb'
import { SqlWeb } from 'sqlweb'
The default export is a constructor/plugin function. Named export is not available.
SqlWeb (type)
import type SqlWeb from 'sqlweb'
import { SqlWeb } from 'sqlweb'
If using TypeScript, import the type if you only need the type definition (not the value).
JsStore
import * as JsStore from 'jsstore'
import JsStore from 'jsstore'
JsStore requires namespace import (import *) because it exports multiple functions as named exports.

Shows basic setup of SqlWeb with JsStore: create connection, add plugin, run SQL queries including CREATE TABLE, INSERT, and SELECT.

import * as JsStore from 'jsstore'; import SqlWeb from 'sqlweb'; const workerPath = 'path/to/jsstore.worker.js'; // or use CDN const connection = new JsStore.Instance(workerPath); async function main() { await connection.addPlugin(SqlWeb); // Create table (if not exists) and insert data const createResult = await connection.$sql.run(` CREATE TABLE IF NOT EXISTS Customers ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT ) `); console.log('Table created:', createResult); const insertResult = await connection.$sql.run(` INSERT INTO Customers (name, email) VALUES ('John Doe', 'john@example.com') `); console.log('Insert result:', insertResult); const rows = await connection.$sql.run('SELECT * FROM Customers'); console.log('All customers:', rows); } main().catch(console.error);
Debug
Known issues
gotchaSqlWeb is a plugin for JsStore—you must add it to an existing JsStore connection before using $sql.
fix
Call connection.addPlugin(SqlWeb) after creating the connection instance.
affects: >=1.0.0
gotchaThe SQL syntax supported by SqlWeb is a subset of standard SQL; not all SQL features are available (e.g., JOINs may be limited).
fix
Refer to SqlWeb documentation or source for supported SQL syntax.
affects: >=1.0.0
gotchaTable and column names are case-sensitive in IndexedDB; SQL queries must match exactly.
fix
Use consistent casing when creating tables and querying them.
affects: >=1.0.0
gotchaTransactions are automatically handled; explicit BEGIN/COMMIT are not supported.
fix
Each $sql.run call is a separate transaction. Group operations carefully.
affects: >=1.0.0
Errors
Common errors & fixes
Uncaught (in promise) TypeError: connection.$sql is undefined
Forgot to call connection.addPlugin(SqlWeb) before using $sql.
fix
Add connection.addPlugin(SqlWeb) after creating the connection.
Error: SqlWeb plugin requires jsstore >=4.0.3
Installed version of jsstore is older than 4.0.3.
fix
Run 'npm install jsstore@latest' to update to a compatible version.
Uncaught (in promise) DOMException: Failed to execute 'transaction' on 'IDBDatabase': One or more of the specified object stores is not found.
Trying to query a table that doesn't exist or hasn't been created with the correct name.
fix
Verify the table name matches exactly (case-sensitive) and that it was created before the query.
Upgrade
Version history
1.6.2latest on npm
Audit
Dependencies
jsstorerequiredRuntime peer dependency; SqlWeb is a plugin for JsStore and cannot function without it.
Agent activity
14 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources
packagesqlweb
sqlweb — npm install sqlweb · libregistry