SqliteEngine
Defined in: libs/runtime/src/sqlite-engine.ts:29
A SQLite engine behind TypeDBLiteDatabase’s five methods.
Async throughout because the port is, not because SQLite is: node:sqlite is synchronous, and
pretending otherwise here would be the only honest place to hide a future async engine.
Member summary
Section titled “Member summary”Constructors
| Name | Description |
|---|---|
| new SqliteEngine() | Opens a database and an interpreter over it. |
Accessors
| Name | Description |
|---|---|
| changeLog | This engine’s change log. |
| hasSchema | Whether a schema has been applied to this database — survives a reopen. |
Methods
| Name | Description |
|---|---|
| close() | Closes the database. |
| define() | Applies schema definitions: the define of the interpreter. |
| execute() | Runs a pipeline for its effect and returns the execution report. |
| persist() | A no-op, and TypeDBLiteDatabase.persist is documented as one so a caller can persist unconditionally after a write. |
| query() | Runs a pipeline and returns its rows. |
| schemaSnapshot() | The schema applied to this database, as sorted lists. |
| transaction() | Run work in one transaction: BEGIN IMMEDIATE, then COMMIT if it resolves or ROLLBACK if it throws, rethrowing the same error. |
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SqliteEngine(
location?,options?):SqliteEngine
Defined in: libs/runtime/src/sqlite-engine.ts:38
Opens a database and an interpreter over it.
Parameters
Section titled “Parameters”location?
Section titled “location?”string = ':memory:'
:memory:, or the path of a SQLite file.
options?
Section titled “options?”TypeDBLiteOptions = {}
How the interpreter opens the database and runs queries.
Returns
Section titled “Returns”SqliteEngine
Accessors
Section titled “Accessors”changeLog
Section titled “changeLog”Get Signature
Section titled “Get Signature”get changeLog():
ChangeLog
Defined in: libs/runtime/src/sqlite-engine.ts:53
This engine’s change log.
Returns
Section titled “Returns”hasSchema
Section titled “hasSchema”Get Signature
Section titled “Get Signature”get hasSchema():
boolean
Defined in: libs/runtime/src/sqlite-engine.ts:58
Whether a schema has been applied to this database — survives a reopen.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”close()
Section titled “close()”close():
Promise<void>
Defined in: libs/runtime/src/sqlite-engine.ts:123
Closes the database.
Returns
Section titled “Returns”Promise<void>
define()
Section titled “define()”define(
schema):Promise<unknown>
Defined in: libs/runtime/src/sqlite-engine.ts:68
Applies schema definitions: the define of the interpreter. Safe to repeat.
Parameters
Section titled “Parameters”schema
Section titled “schema”string
Returns
Section titled “Returns”Promise<unknown>
execute()
Section titled “execute()”execute(
query):Promise<unknown>
Defined in: libs/runtime/src/sqlite-engine.ts:73
Runs a pipeline for its effect and returns the execution report.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<unknown>
persist()
Section titled “persist()”persist():
Promise<void>
Defined in: libs/runtime/src/sqlite-engine.ts:92
A no-op, and TypeDBLiteDatabase.persist is documented as one so a caller can persist
unconditionally after a write.
A file-backed SQLite database has already written by the time this is called: the interpreter commits each pipeline. There is no snapshot to take.
Returns
Section titled “Returns”Promise<void>
query()
Section titled “query()”query(
query):Promise<{rows: readonlyEngineRow[]; }>
Defined in: libs/runtime/src/sqlite-engine.ts:81
Runs a pipeline and returns its rows.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<{ rows: readonly EngineRow[]; }>
schemaSnapshot()
Section titled “schemaSnapshot()”schemaSnapshot():
TypeDBLiteSchemaSnapshot
Defined in: libs/runtime/src/sqlite-engine.ts:63
The schema applied to this database, as sorted lists.
Returns
Section titled “Returns”transaction()
Section titled “transaction()”transaction<
T>(work):Promise<T>
Defined in: libs/runtime/src/sqlite-engine.ts:104
Run work in one transaction: BEGIN IMMEDIATE, then COMMIT if it resolves or ROLLBACK if it throws,
rethrowing the same error. Inside work, this engine’s own execute and query are in the transaction.
One handle, one transaction at a time. Two overlapping calls on the same engine would share one SQLite connection
and so one transaction; TypeDBLiteDatabase serializes them, and a second BEGIN here is refused rather than
silently joined.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”() => Promise<T>
Returns
Section titled “Returns”Promise<T>
TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.