ReadonlykindIdentifier for logging/diagnostics (e.g., 'better-sqlite3', 'postgres').
ReadonlycapabilitiesCapability flags indicating supported features.
Opens IndexedDB and initializes sql.js database. Loads existing database from IndexedDB if present.
Optional_options: StorageOpenOptionsExecutes a SQL statement that doesn't return rows (INSERT, UPDATE, DELETE, CREATE, etc.).
SQL statement with ? or :name placeholders
Optionalparameters: StorageParametersPositional array or named object
Result with changes count and last insert row ID
Executes a SQL query and returns the first row.
SELECT statement
Optionalparameters: StorageParametersQuery parameters
First row as object or null if no results
Executes a SQL query and returns all matching rows.
SELECT statement
Optionalparameters: StorageParametersQuery parameters
Array of result rows as objects
Executes a callback within a database transaction.
Storage adapter using IndexedDB + sql.js for client-side SQL persistence.
The Key Difference: Automatic Persistence
sql.js adapter alone:
db.export()and save it yourselfIndexedDB adapter (this):
Is This Necessary?
✅ YES if you need:
❌ NO if you:
Alternative: You could use sql.js directly and manually save to IndexedDB yourself, but you'd lose:
Bottom line: This adapter is necessary for production web apps that need persistence. For prototypes or edge functions, sql.js alone is fine.
How It Works:
Why IndexedDB + sql.js?
Capabilities:
Performance:
Example: Client-side application