SQLite
SQLite is an embedded relational database. It stores data in a single file, or fully in memory for ephemeral use.
Setup
Install
npm install @primate/sqlite
Configure
// config/db.ts
import sqlite from "@primate/sqlite";
export default sqlite({
// database: ":memory:", // in-memory (default)
// database: "/var/data.db", // file path (persists)
// readonly: true, // reject database writes
});
Transactions
db.transaction() starts BEGIN IMMEDIATE and holds SQLite's database-wide
write fence. SQLite has no row-level equivalent of SELECT ... FOR UPDATE;
Store.lock() reads and returns the primary-key row under the transaction's
existing coarse fence, which is what excludes other writers. See the
Store transaction contract for lifecycle and error behavior.
Options
| option | type | default | description |
|---|---|---|---|
| database | string |
":memory:" |
Path to a database file, or ":memory:" |
| readonly | boolean |
false |
Open the database without write access |
":memory:" uses an in-memory database. It does not persist across runs.
Set readonly: true when a process must only inspect an existing database, such
as a status-only deployment check. Migration apply requires a writable SQLite
configuration. Inspecting migrations against a missing file reports an empty,
uninitialized database without creating the file.