Driver Sqlite
Driver Sqlite protocol schemas
SQLite driver configuration — the config slot of a datasource whose
driver resolves to sqlite (native better-sqlite3, with the dev-only
step-down to wasm then in-memory, #2229) or to sqlite-wasm (pure-JS).
The one key that matters is filename, and it is exactly the key the silent
strip used to hide: an author who wrote path: got no error, the connection
fell back to :memory:, and their data vanished on restart with every signal
saying the datasource was configured.
file and database once also worked, purely because the factory read them
as undeclared ?? fallbacks. That tolerance has graduated into the declared
ADR-0087 conversion datasource-config-driver-key-aliases (#4456): stored
rows are rewritten to filename at load, the factory reads one spelling,
and authoring rejects both with the rename hint below.
Source: packages/spec/src/data/driver/sqlite.zod.ts
TypeScript Usage
import { SqliteConfigSchema, SqliteWasmConfigSchema, SqliteWasmPersistModeSchema } from '@objectstack/spec/data';
import type { SqliteConfig, SqliteWasmConfig, SqliteWasmPersistMode } from '@objectstack/spec/data';
// Validate data
const result = SqliteConfigSchema.parse(data);SqliteConfig
SQLite connection configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| filename | string | optional (default: ":memory:") | Database file path, or ":memory:" for an ephemeral database |
| autoMigrate | Enum<'off' | 'safe'> | optional | Dev-only non-destructive schema self-heal (#2186) |
SqliteWasmConfig
SQLite (WASM) connection configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| filename | string | optional (default: ":memory:") | Database file path, or ":memory:" for an ephemeral database |
| persist | 'on-disconnect' | 'on-write' | string | optional | When to flush a file-backed wasm database to disk |
SqliteWasmPersistMode
When to flush a file-backed wasm database to disk
Union Options
This schema accepts one of the following structures:
Option 1
Type: 'on-disconnect'
Option 2
Type: 'on-write'
Option 3
Type: string