{"library":"sqlite-level","title":"SQLite-backed Abstract LevelDB","type":"library","description":"sqlite-level is a Node.js library that provides an `abstract-level` compliant interface, backed by a SQLite database. It leverages `better-sqlite3` for its underlying SQLite operations, offering a synchronous-like API while maintaining `abstract-level` compatibility. This allows developers familiar with the LevelDB API to utilize a durable, file-based store without needing to manage separate database processes or complex setups typical of other embedded databases. Currently stable at version 1.2.1, its release cadence is tied to the needs of the TinaCMS project, ensuring ongoing maintenance and updates. A key differentiator is its use of SQLite, offering ACID properties and wide tooling support, contrasting with LevelDB's LSM-tree design. It's particularly useful for server-side applications requiring a lightweight, transactional key-value store with data persistence for development or smaller deployments.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install sqlite-level"],"cli":null},"imports":["import { Level } from 'sqlite-level';","import type { LevelOptions } from 'sqlite-level';"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/tinacms/sqlite-level","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/sqlite-level","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { Level } from 'sqlite-level';\nimport { join } from 'path';\nimport { tmpdir } from 'os';\n\nasync function runExample() {\n  const dbPath = join(tmpdir(), 'my_sqlite_level_db.sqlite');\n  const db = new Level(dbPath);\n\n  try {\n    console.log(`Opening database at: ${dbPath}`);\n    await db.open();\n    console.log('Database opened.');\n\n    await db.put('name', 'Alice');\n    await db.put('age', '30');\n\n    const name = await db.get('name');\n    const age = await db.get('age');\n    console.log(`Name: ${name}, Age: ${age}`);\n\n    // Iterate over entries\n    console.log('Iterating over entries:');\n    for await (const [key, value] of db.iterator({ gte: 'a', lt: 'z' })) {\n      console.log(`  Key: ${key}, Value: ${value}`);\n    }\n\n    await db.del('age');\n    const newAge = await db.get('age');\n    console.log(`Age after deletion: ${newAge}`); // Should be undefined\n  } catch (error) {\n    console.error('An error occurred:', error);\n  } finally {\n    if (!db.isClosed()) {\n      await db.close();\n      console.log('Database closed.');\n    }\n  }\n}\n\nrunExample();","lang":"typescript","description":"Demonstrates opening a SQLite-backed LevelDB, performing basic put, get, delete operations, and iterating over stored keys and values, ensuring proper database closure.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}