Registry / database / deepbase-drizzle

deepbase-drizzle

JSON →
library3.6.9jsnpmunverified

DeepBase-nested-object database driver for Drizzle ORM (v3.6.9, stable, weekly releases). Unlike dialect-specific drivers (deepbase-sqlite, deepbase-mysql), deepbase-drizzle works with any Drizzle-supported database (SQLite, PostgreSQL, MySQL, etc.) by accepting a Drizzle `db` instance. Automatically creates storage tables on connect. Maintains `seq` column for stable insertion order, supporting `shift()` and `pop()`. ESM-only, requires TypeScript 5+.

npm install deepbase-drizzle
INSTALL
IMPORT
SIG · DEEPBASE-DRIZZLE
D
deepbase-drizzle
databasejavascriptv3.6.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DrizzleDriver
import DrizzleDriver from 'deepbase-drizzle'
const DrizzleDriver = require('deepbase-drizzle')
ESM-only default export; CJS require() will fail with ERR_REQUIRE_ESM
DeepBase
import DeepBase from 'deepbase'
import { DeepBase } from 'deepbase'
DeepBase is a default export, not named export
drizzle
import { drizzle } from 'drizzle-orm/better-sqlite3'
import { drizzle } from 'drizzle-orm'
drizzle() must be imported from the dialect-specific subpath (better-sqlite3, node-postgres, mysql2, etc.)

Creates a DeepBase store backed by SQLite via Drizzle ORM; sets and retrieves nested keys.

import Database from 'better-sqlite3'; import { drizzle } from 'drizzle-orm/better-sqlite3'; import DeepBase from 'deepbase'; import DrizzleDriver from 'deepbase-drizzle'; const sqlite = new Database('app.db'); const db = drizzle({ client: sqlite }); const store = new DeepBase( new DrizzleDriver({ db, client: sqlite, tableName: 'my_data' }) ); await store.connect(); // auto-creates table await store.set('user', 'alice', { age: 30, email: 'alice@example.com' }); const alice = await store.get('user', 'alice'); console.log(alice); // { age: 30, email: 'alice@example.com' } const keys = await store.keys('user'); console.log(keys); // ['alice'] await store.close(); sqlite.close();
Debug
Known issues
breakingv3 migration: DrizzleDriver v3 changed from named export to default export (was `import { DrizzleDriver } from 'deepbase-drizzle'`; now `import DrizzleDriver from 'deepbase-drizzle'`).
fix
Use default import: `import DrizzleDriver from 'deepbase-drizzle'`
affects: >=3.0.0 <3.6.9
deprecatedThe `driver` option in DrizzleDriver constructor is deprecated. Use `db` instead.
fix
Replace `driver: myDriver` with `db: myDriver`
affects: >=3.0.0 <3.6.9
gotchaTable auto-creation may fail if the database user lacks CREATE TABLE privileges (e.g., read-only replicas).
fix
Set `ensureTable: false` and create the table manually using the schema from the README.
affects: >=3.0.0
gotchaUpsert behavior: inserting a key that already exists updates `value` but does NOT increment `seq`. This breaks FIFO order assumptions if you rely on `seq` for insertion order.
fix
If you need strict insertion ordering, use `store.set()` only for new keys or manually manage `seq`.
affects: >=3.0.0
gotcha`reopen` factory must return an object with `db` (and optionally `client`). If `client` is returned but does not have a `.close()` method, the default disconnect will throw.
fix
Ensure the factory returns an object with `{ db, client }` and that `client.close()` exists if you intend to use default disconnect logic.
affects: >=3.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using CommonJS `require()` to import an ESM-only package
fix
Use `import DrizzleDriver from 'deepbase-drizzle'` in an ESM context, or use dynamic `import()` in CJS.
TypeError: drizzle is not a function
Importing `drizzle` from the top-level `drizzle-orm` package instead of a dialect subpath
fix
Replace `import { drizzle } from 'drizzle-orm'` with `import { drizzle } from 'drizzle-orm/better-sqlite3'` (or your dialect).
Error: table "deepbase_main" does not exist
Table auto-creation is disabled or failed; default table name is `deepbase_main`
fix
Either call `.connect()` (which auto-creates by default) or manually create the table using the schema: `CREATE TABLE deepbase_main (key TEXT PRIMARY KEY, value TEXT, seq INTEGER)`.
TypeError: Cannot destructure property 'db' of 'undefined'
Missing `db` in DrizzleDriver options
fix
Pass `{ db: myDrizzleInstance }` to the DrizzleDriver constructor.
Upgrade
Version history
3.6.9latest on npm
Audit
Dependencies
deepbaserequiredCore DeepBase runtime for nested-key operations; must match major version
Agent activity
5 hits · last 30 days
node
4
Resources