stable

sqlite

Single-file SQLite adapter for noy-db, for 10K+ records — duck-typed Database interface accepts better-sqlite3, node:sqlite, or bun:sqlite.

@noy-db/to-sqlite · pnpm add @noy-db/to-sqlite Single-file local encrypted document store.

Shaperecord
Atomic CAS✓
Localitylocal
Speedfast
Persistencedurable

What it does

Persists a vault to a single SQLite file — a good fit once a vault outgrows to-file's one-JSON-per-record layout (10K+ records). Accepts a duck-typed Database interface, so better-sqlite3, node:sqlite (Node 22+), bun:sqlite, or any driver matching the same shape all work.

Notes

  • casAtomic: true via UPDATE … WHERE _v = ? inside a BEGIN IMMEDIATE transaction.
  • Record shape, one row per record.
  • Same table and DDL as turso, so moving from a local file to hosted libSQL is a factory swap.
  • Factory: toSqlite(options: SqliteStoreOptions).

Store-locator descriptor

See store-locator descriptors for the general model. kind: 'sqlite', class: 'local'. address is { file?, table? }: table maps to tableName; file is identity-only, not consumed by the factory — the connection already carries it. options is { autoMigrate? }. binding.client is required (a SqliteDatabase, mapped onto the store's own db option) — this store has no client library of its own; resolve() without it throws.

import { sqliteStoreDescriptor, registerSqliteStore } from '@noy-db/to-sqlite'

const descriptor = sqliteStoreDescriptor({ file: './vault.db', table: 'noydb_envelopes' })

See also