{"id":44979,"library":"flextree-sqlite-adapter","title":"flextree-sqlite-adapter","description":"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.","status":"active","version":"2.0.4","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/zhangfisher/flextree","tags":["javascript","flextree","sqlite","tree storage","typescript"],"install":[{"cmd":"npm install flextree-sqlite-adapter","lang":"bash","label":"npm"},{"cmd":"yarn add flextree-sqlite-adapter","lang":"bash","label":"yarn"},{"cmd":"pnpm add flextree-sqlite-adapter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"core library for tree data structures","package":"flextree","optional":false},{"reason":"synchronous SQLite3 driver for Node.js","package":"better-sqlite3","optional":false}],"imports":[{"note":"Named export only. No default export.","wrong":"import SqliteAdapter from 'flextree-sqlite-adapter'","symbol":"SqliteAdapter","correct":"import { SqliteAdapter } from 'flextree-sqlite-adapter'"},{"note":"Type-only import for TypeScript users.","wrong":"import { SqliteAdapterOptions } from 'flextree-sqlite-adapter'","symbol":"SqliteAdapterOptions","correct":"import type { SqliteAdapterOptions } from 'flextree-sqlite-adapter'"},{"note":"CommonJS require will result in undefined (ESM-only package).","wrong":"const adapter = require('flextree-sqlite-adapter')","symbol":"adapter","correct":"import { adapter } from 'flextree-sqlite-adapter'"}],"quickstart":{"code":"import { SqliteAdapter } from 'flextree-sqlite-adapter';\nimport Database from 'better-sqlite3';\nimport { Flextree } from 'flextree';\n\nconst db = new Database('mydb.sqlite');\nconst adapter = new SqliteAdapter(db, { tableName: 'nodes' });\nadapter.initialize();\n\nconst tree = new Flextree(adapter);\ntree.insert({ id: '1', parentId: null, data: { name: 'root' } });\ntree.insert({ id: '2', parentId: '1', data: { name: 'child' } });\n\nconsole.log(tree.toJSON());\ndb.close();","lang":"typescript","description":"Creates a SQLite adapter, initializes the table, and performs basic tree operations using flextree."},"warnings":[{"fix":"Update constructor call to new SqliteAdapter(db, { tableName: 'nodes' })","message":"Version 2.0.0 changed the adapter constructor signature from (db, tableName) to (db, options).","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Ensure Database constructor is called with the file path or ':memory:'.","message":"Adapter does not create the database file automatically; the database must be opened before passing to adapter.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use better-sqlite3 as the database driver.","message":"The adapter expects a synchronous sqlite3 driver (better-sqlite3). Do not use with async drivers like sql.js.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use { table: 'nodes' } instead of { tableName: 'nodes' }.","message":"The option 'tableName' is deprecated in favor of 'table' in version 2.0.3.","severity":"deprecated","affected_versions":">=2.0.3"}],"env_vars":null,"search_vec":"'2.0.4':16 'adapt':4,6,20 'addit':49 'configur':42 'core':35 'coupl':31 'current':14 'data':27 'differenti':39 'direct':44 'enabl':9 'flextre':2,8,33,47,53 'flextree-sqlite-adapt':1 'hierarch':26 'integr':45 'interfac':21 'javascript':52 'key':38 'layer':51 'lightweight':40 'manipul':37 'minim':41 'orm':50 'persist':10 'provid':17 'retriev':25 'sqlite':3,5,29,54 'storag':13,56 'store':23 'straightforward':19 'structur':12 'tight':30 'tree':11,36,55 'typescript':57 'use':28 'version':15 'without':48","created_at":"2026-06-07T12:52:46.716346+00:00","updated_at":"2026-06-07T12:52:46.716346+00:00","problems":[{"fix":"import { SqliteAdapter } from 'flextree-sqlite-adapter'","cause":"Using default import instead of named import.","error":"TypeError: SqliteAdapter is not a constructor"},{"fix":"npm install better-sqlite3","cause":"Missing peer dependency better-sqlite3.","error":"Error: Cannot find module 'better-sqlite3'"},{"fix":"Ensure adapter is created with new and initialize() is called after constructor.","cause":"Calling initialize on an uninitialized adapter or using wrong import.","error":"TypeError: adapter.initialize is not a function"},{"fix":"Call adapter.initialize() before performing operations.","cause":"The table was not created; initialize() was not called.","error":"SqliteError: no such table: nodes"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://zhangfisher.github.io/flextree/","github":"ssh://git@github.com/zhangfisher/flextree","docs":null,"changelog":null,"pypi":null,"npm":"flextree-sqlite-adapter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}