Skip to content

zidane/durable/node-sqlite

A SQLite driver for the durable kernel on Node, through node:sqlite.

import { … } from 'zidane/durable/node-sqlite'src/durable/storage/sqlite-node.ts

Use nodeSqliteDriver to keep durable records in a SQLite file on Node. Pass the driver to sqliteStorage from zidane/durable, then open the kernel on that storage. It takes a path, :memory:, or an open DatabaseSync. With a path, the driver creates a missing file and closes the connection itself. With an open DatabaseSync, you close it. It sets WAL with synchronous = FULL on the connection. It needs a Node version with node:sqlite. On Bun, use bunSqliteDriver from zidane/durable/sqlite. See durable tasks and hosts.

TypeScript
import { openDurable, sqliteStorage } from 'zidane/durable'
import { nodeSqliteDriver } from 'zidane/durable/node-sqlite'

const storage = sqliteStorage(nodeSqliteDriver('./durable.db'))
const durable = await openDurable({ storage })
await durable.resumeLive()

Functions#

nodeSqliteDriverFunction#

A driver over the SQLite file at target, or over an open DatabaseSync. With a path, the driver creates the file when it is missing, and it closes the connection it opened. With an open database, the caller closes it. Either way it sets the file pragmas (applyFilePragmas) on the connection.

TypeScript
function nodeSqliteDriver(target: string | DatabaseSync): SqliteDriver
Parameters
NameTypeDescription
targetstring | DatabaseSync

A path, :memory:, or an open database.

src/durable/storage/sqlite-node.ts:15