SQLite adapter implementing the db-adapter interface.
Wraps better-sqlite3 to provide the standard adapter API used by all
repository modules. This is the default adapter when no DATABASE_URL
environment variable is set (or when it does not start with postgres://).
Adapter interface
Every adapter must expose:
prepare(sql)→ statement-like object with.run(),.get(),.all()exec(sql)— execute raw SQL (DDL, multi-statement)transaction(fn)— wrapfnin a transaction, return a callablepragma(str)— execute a PRAGMA (no-op on non-SQLite)close()— close the connectiondialect—"sqlite"or"postgres"
Members
(inner) dialect :"sqlite"
Type:
- "sqlite"
Methods
(static) createSqliteAdapter(optsopt) → {Object}
Create a SQLite adapter instance.
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
<optional> |
Properties
|
Returns:
Adapter conforming to the db-adapter interface.
- Type
- Object
(inner) close()
Gracefully close the database connection. Checkpoints the WAL file before closing.
(inner) exec(sql)
Execute raw SQL (DDL, multi-statement scripts).
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string |
(inner) pragma(str) → {*}
Execute a PRAGMA statement.
Parameters:
| Name | Type | Description |
|---|---|---|
str |
string | — e.g. "journal_mode = WAL" |
Returns:
- Type
- *
(inner) prepare(sql) → {Object}
Prepare a SQL statement.
Returns the native better-sqlite3 Statement which already has
.run(), .get(), .all() methods.
Parameters:
| Name | Type | Description |
|---|---|---|
sql |
string |
Returns:
better-sqlite3 Statement
- Type
- Object
(inner) transaction(fn) → {function}
Wrap a function in a database transaction.
Returns a callable that executes fn inside BEGIN/COMMIT.
Parameters:
| Name | Type | Description |
|---|---|---|
fn |
function |
Returns:
- Type
- function