Registry / database / sqlite-tree-store

sqlite-tree-store

JSON →
library1.1.7jsnpmunverified

A lightweight, schema-less document store built on SQLite, designed for quick prototyping and storing config data. Current stable version is 1.1.7. It uses better-sqlite3 under the hood and exposes a JavaScript Proxy-based tree interface for CRUD operations. Unlike full MongoDB, it leverages SQLite for persistence without a separate server. Key differentiators: auto-save to DB, ability to break binding (._) for transient changes, and meta-data access. Release cadence is low; version 1.x is stable. Not actively maintained; last release was in 2020.

npm install sqlite-tree-store
INSTALL
IMPORT
SIG · SQLITE-TREE-STORE
S
sqlite-tree-store
databasejavascriptv1.1.7
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.

default
const treeStore = require('sqlite-tree-store')
import treeStore from 'sqlite-tree-store'
Package is CJS-only; ESM import will fail with ERR_REQUIRE_ESM
tree()
const t = treeStore('mydb.db', 'system')()
const t = treeStore('mydb.db', 'system').tree()
treeStore returns a builder function; invoke it with no args to get root proxy. tree() is not exported directly.
Default (typed)
import treeStore from 'sqlite-tree-store' // @ts-ignore
import { treeStore } from 'sqlite-tree-store'
No TypeScript types; use @ts-ignore or create .d.ts. Default import is CJS default.

Demonstrates initializing store, creating root proxy, and setting nested properties with auto-save.

const treeStore = require('sqlite-tree-store'); const build = treeStore('test.db', 'system'); const t = build(); t.config = { mail: { host: 'example.com', port: 25 } }; t.config.ssl = { certFile: 'main.pfx' }; console.log(t); // shows { config: { mail: ..., ssl: ... } }
Debug
Known issues
breakingrequire('sqlite-tree-store') returns a function (factory), not an object with methods.
fix
Use as: const treeStore = require('sqlite-tree-store'); const build = treeStore('path.db', 'tableName'); const t = build();
affects: >=1.0.0
gotchaAssigning a value directly to a proxy property triggers auto-save, which may cause performance issues on large writes.
fix
Use the `._` binding break for transient changes: t.config.mail._.port = 10025; changes won't persist.
affects: >=1.0.0
gotchaThe package depends on better-sqlite3 which requires native compilation; may fail in browser or certain CI environments.
fix
Ensure build tools (node-gyp, python) are present; for CI, use prebuilt binaries via better-sqlite3's prebuildify.
affects: >=1.0.0
breakingIn version 1.1.0, the tree() function signature changed: depth parameter added. Old code calling tree() with depth argument may behave differently.
fix
If using depth, pass as second argument: tree([], 1). For full tree, omit both arguments: tree().
affects: >=1.1.0
Errors
Common errors & fixes
Error: Cannot find module 'better-sqlite3'
Peer dependency better-sqlite3 not installed.
fix
npm install better-sqlite3
TypeError: treeStore is not a function
Importing via ES6 import syntax instead of require.
fix
Use const treeStore = require('sqlite-tree-store')
Error: SQLITE_ERROR: no such table: system
Table name in call does not match existing table; or store not initialized.
fix
Ensure consistent table name: const build = treeStore('mydb.db', 'mytable'); then build() creates table 'mytable' and view 'v_mytable'.
Upgrade
Version history
1.1.7latest on npm
Audit
Dependencies
better-sqlite3requiredUnderlying SQLite engine; required at runtime
Agent activity
15 hits · last 30 days
node
12
Meta
2
OpenAI (training)
1
Resources
sqlite-tree-store — npm install sqlite-tree-store · libregistry