{"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,"search_vec":"'2.7.0':17 'activ':53 'async':22 'built':37 'built-in':36 'cadenc':59 'connect':49 'current':14 'databas':2,68 'database-sempai':1 'db':65 'dbd':66 'driven':46 'e.g':31 'encrypt':27 'enmap':33 'event':45 'event-driven':44 'file':13,23 'filter':41 'javascript':64 'json':12,67 'key':7 'key-valu':6 'librari':10,51 'like':40 'lowdb':32 'maintain':54 'method':39 'multipl':20 'offer':35 'oper':24 'option':26 'packag':30 'randomat':42 'readi':47 'releas':58 'sempai':3 'ship':61 'similar':29 'sql':69 'stabl':57 'storag':9 'support':19 'tabl':21 'type':63 'typescript':5,62,70 'unlik':28 'use':11 'valu':8 'version':16 'via':48","created_at":"2026-05-09T05:51:30.341809+00:00","updated_at":"2026-05-09T05:51:30.341809+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Sempai-07/database-sempai","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/database-sempai","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","serialization","auth-security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-09","next_check":"2026-08-07","install_tag":null}}