Registry / database / flextree-sqlite-adapter

flextree-sqlite-adapter

JSON →
library2.0.4jsnpmunverified

SQLite adapter for flextree, enabling persistent tree structure storage. Current version 2.0.4. Provides a straightforward adapter interface to store and retrieve hierarchical data using SQLite, tightly coupled with flextree's core tree manipulation. Key differentiator: lightweight, minimal configuration, and directly integrates with flextree without additional ORM layers.

npm install flextree-sqlite-adapter
INSTALL
IMPORT
SIG · FLEXTREE-SQLITE-AD
F
flextree-sqlite-adapter
databasejavascriptv2.0.4
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.

SqliteAdapter
import { SqliteAdapter } from 'flextree-sqlite-adapter'
import SqliteAdapter from 'flextree-sqlite-adapter'
Named export only. No default export.
SqliteAdapterOptions
import type { SqliteAdapterOptions } from 'flextree-sqlite-adapter'
import { SqliteAdapterOptions } from 'flextree-sqlite-adapter'
Type-only import for TypeScript users.
adapter
import { adapter } from 'flextree-sqlite-adapter'
const adapter = require('flextree-sqlite-adapter')
CommonJS require will result in undefined (ESM-only package).

Creates a SQLite adapter, initializes the table, and performs basic tree operations using flextree.

import { SqliteAdapter } from 'flextree-sqlite-adapter'; import Database from 'better-sqlite3'; import { Flextree } from 'flextree'; const db = new Database('mydb.sqlite'); const adapter = new SqliteAdapter(db, { tableName: 'nodes' }); adapter.initialize(); const tree = new Flextree(adapter); tree.insert({ id: '1', parentId: null, data: { name: 'root' } }); tree.insert({ id: '2', parentId: '1', data: { name: 'child' } }); console.log(tree.toJSON()); db.close();
Debug
Known issues
breakingVersion 2.0.0 changed the adapter constructor signature from (db, tableName) to (db, options).
fix
Update constructor call to new SqliteAdapter(db, { tableName: 'nodes' })
affects: <2.0.0
gotchaAdapter does not create the database file automatically; the database must be opened before passing to adapter.
fix
Ensure Database constructor is called with the file path or ':memory:'.
affects: >=2.0.0
gotchaThe adapter expects a synchronous sqlite3 driver (better-sqlite3). Do not use with async drivers like sql.js.
fix
Use better-sqlite3 as the database driver.
affects: >=2.0.0
deprecatedThe option 'tableName' is deprecated in favor of 'table' in version 2.0.3.
fix
Use { table: 'nodes' } instead of { tableName: 'nodes' }.
affects: >=2.0.3
Errors
Common errors & fixes
TypeError: SqliteAdapter is not a constructor
Using default import instead of named import.
fix
import { SqliteAdapter } from 'flextree-sqlite-adapter'
Error: Cannot find module 'better-sqlite3'
Missing peer dependency better-sqlite3.
fix
npm install better-sqlite3
TypeError: adapter.initialize is not a function
Calling initialize on an uninitialized adapter or using wrong import.
fix
Ensure adapter is created with new and initialize() is called after constructor.
SqliteError: no such table: nodes
The table was not created; initialize() was not called.
fix
Call adapter.initialize() before performing operations.
Upgrade
Version history
2.0.4latest on npm
Audit
Dependencies
flextreerequiredcore library for tree data structures
better-sqlite3requiredsynchronous SQLite3 driver for Node.js
Agent activity
10 hits · last 30 days
node
8
Amazon
1
Resources
flextree-sqlite-adapter — npm install flextree-sqlite-adapter · libregistry