SqljsAdapter
SqljsAdapter is the Adapter implementation shipped by
@sqb/sqljs, running SQLite compiled to WebAssembly via
sql.js. It self-registers with AdapterRegistry as a side
effect of importing @sqb/sqljs — see the
SQLite (WebAssembly / sql.js) adapter guide for setup
and configuration.
import '@sqb/sqljs';
Constructor
new SqljsAdapter()
Takes no arguments. You normally never construct this directly — importing @sqb/sqljs
registers a shared instance with AdapterRegistry for you.
Properties
| Property | Type | Description |
|---|---|---|
driver | 'sqljs' | The driver name, matched against ClientConfiguration.driver. |
dialect | 'sqlite' | The dialect name — shared with @sqb/sqlite, since both generate standard SQLite SQL. Select this adapter with driver: 'sqljs' if both are registered in the same process. |
features | Adapter.Features | { cursor: true }. |
Methods
connect()
connect(config: ClientConfiguration): Promise<Adapter.Connection>
Requires config.database (throws if missing). Resolves it to an absolute file path, unless it
matches :memory: (optionally suffixed, e.g. :memory:name), in which case a fresh in-memory
sql.js database is created instead. For a file path, the file's contents are read up-front via
fs.readFile and loaded into an in-memory sql.js Database. Non-memory databases are cached
and reference-counted by resolved path, so multiple connections to the same file share one
sql.js Database instance. Returns a SqljsConnection wrapping the opened (or reused)
database.
Other exports
closeMemoryDatabase()
function closeMemoryDatabase(name?: string): Promise<void>
Force-closes and evicts a cached in-memory database (:memory: by default, or the given
:memory:name variant) from the adapter's internal cache.
See also
- SQLite (WebAssembly / sql.js) adapter guide
SqliteAdapter— the native SQLite alternativeAdapterinterfaceAdapterRegistry