{"id":27677,"library":"database-sempai","title":"database-sempai","description":"A TypeScript key-value storage library using JSON files, currently at version 2.7.0. It supports multiple tables, async file operations, and optional encryption. Unlike similar packages (e.g., lowdb, enmap), it offers built-in methods like filter, randomAt, and event-driven readiness via connect. The library is actively maintained with a stable release cadence, and ships TypeScript types.","status":"active","version":"2.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/Sempai-07/database-sempai","tags":["javascript","db","dbd","json","database","sql","typescript"],"install":[{"cmd":"npm install database-sempai","lang":"bash","label":"npm"},{"cmd":"yarn add database-sempai","lang":"bash","label":"yarn"},{"cmd":"pnpm add database-sempai","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports CreateStorage as a named export. Default import will not work.","wrong":"import CreateStorage from 'database-sempai'","symbol":"CreateStorage","correct":"import { CreateStorage } from 'database-sempai'"},{"note":"The package supports ESM only. CommonJS require is not supported.","wrong":"const { CreateStorage } = require('database-sempai')","symbol":"CreateStorage","correct":"import { CreateStorage } from 'database-sempai'"},{"note":"TableKey is a type-only export. Use import type to avoid runtime errors in TypeScript's isolatedModules.","wrong":"import { TableKey } from 'database-sempai'","symbol":"type TableKey","correct":"import type { TableKey } from 'database-sempai'"}],"quickstart":{"code":"import { CreateStorage } from 'database-sempai';\n\nconst db = new CreateStorage<string, string>({\n  path: 'mydb',\n  table: ['users'],\n  extname: '.json',\n});\n\nawait db.set('users', '1', 'Alice');\nawait db.set('users', '2', 'Bob');\nconst all = await db.all('users');\nconsole.log(all); // { '1': 'Alice', '2': 'Bob' }\n\nconst found = await db.findByValue('users', 'Alice');\nconsole.log(found); // { '1': 'Alice' }\n\nawait db.delete('users', '2');\nconsole.log(await db.length('users')); // 1","lang":"typescript","description":"Creates a database, adds two entries, retrieves all, finds by value, deletes one, and shows the length."},"warnings":[{"fix":"Use await or .then() for all method calls (set, get, delete, clear, all, etc.).","message":"In v2.0.0, all methods became async. Synchronous operations will return Promises.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Pass the table name directly to each method instead of relying on a default table from the constructor.","message":"The 'table' option in the constructor is deprecated as of v2.5.0. Use the 'table' parameter in methods instead.","severity":"deprecated","affected_versions":">=2.5.0"},{"fix":"Use firstKey() and firstValue() methods.","message":"The method 'firtsKey' and 'firtsValue' are misspelled and deprecated since v2.5.5. Use 'firstKey' and 'firstValue' instead.","severity":"deprecated","affected_versions":">=2.5.5"},{"fix":"Backup your key. If lost, delete the database files or reinitialize without encryption.","message":"If you provide an encryption key in the config, all data is encrypted. However, without the exact same key, data becomes unreadable and errors will be thrown.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set extname to '.json' explicitly to avoid confusion.","message":"The 'extname' option defaults to '.sql' which may be misleading since the storage is JSON-based. This can cause confusion with actual SQL databases.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'get' to check if a key exists, or 'keys' to list all keys.","message":"Method 'includes' checks for a value, not a key. This is counterintuitive for a key-value store.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Add await before the method call, e.g., await db.set(...)","cause":"Calling an async method without await or .then(). All methods are async since v2.","error":"TypeError: Cannot read properties of undefined (reading 'then')"},{"fix":"Add the table name to the 'table' array in the constructor, or use 'set' method which creates the table implicitly.","cause":"Referencing a table that hasn't been defined in the constructor or created at runtime.","error":"Error: The table 'x' does not exist in the database."},{"fix":"Provide the exact same key used during encryption via the 'key' option in the constructor.","cause":"Attempting to decrypt a previously encrypted database without providing the encryption key.","error":"Error: Encryption key not specified."},{"fix":"Use one of the supported extensions: '.json', '.sql', or '.txt' (though .sql is misleading, use .json).","cause":"Using an unsupported file extension in the 'extname' option.","error":"Error: Invalid file extension: .xyz. Only .json, .sql, and .txt are allowed."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}