berryDB

raw JSON →
1.3.4 verified Sat Apr 25 auth: no javascript

berryDB is a lightweight, file-based relational database tool for Node.js, version 1.3.4. It aims to provide a simple and secure storage solution using a Key Word Storage (KWS) philosophy. Compared to full-featured databases like SQLite or LevelDB, berryDB is minimal and intended for small-scale applications. Release cadence is irregular; the package has seen limited updates and community adoption.

error Error: Cannot find module 'berry-database'
cause The package is not installed in the current directory.
fix
Run 'npm install berry-database' to install the package.
error Error: ENOENT: no such file or directory, open './data/db.json'
cause The database directory does not exist; you must create the database using the CLI tool first.
fix
Install berry-tool and run 'berry -c db yourdbname' to create the database.
error TypeError: db.insert is not a function
cause The 'Database' class may not have been instantiated correctly, or the API has changed.
fix
Ensure you have created the database via CLI and that the library version supports that method. Check the source.
error Dependency not found: berry-tool
cause The berry-tool package is not installed globally.
fix
Run 'npm install -g berry-tool' to install the command-line tool.
gotcha The library requires a separate CLI tool 'berry-tool' to create databases and tables. Without it, you cannot create new databases programmatically.
fix Install berry-tool globally: npm install -g berry-tool, then use CLI commands to set up the database structure.
gotcha The API exposes methods like 'insert', 'select', 'update', 'delete' but the documentation is sparse and may not match actual behavior. The library may have limited error handling.
fix Test operations thoroughly; check the source code on GitHub for accurate method signatures.
deprecated The library appears to be in maintenance mode with infrequent updates. Newer Node.js versions may cause compatibility issues.
fix Consider using a more actively maintained database library like SQLite (better-sqlite3) or LevelDB.
gotcha No types or TypeScript definitions are provided, making integration with TypeScript projects cumbersome.
fix Create your own definition file or use '// @ts-ignore' when importing.
npm install berry-database
yarn add berry-database
pnpm add berry-database

Demonstrates basic CRUD operations after creating a database and table via CLI.

const berry = require('berry-database');

// Example: creating a new database (via CLI, not shown here)
// Then, you can use the library to interact with it.
// Assuming the tool has been used to create a database named 'testdb' and a table 'users'

// Opening the database
const db = new berry.Database('testdb');

// Inserting a record
const result = db.insert('users', { name: 'Alice', age: 30 });
console.log('Inserted ID:', result.id);

// Querying records
const users = db.select('users', { name: 'Alice' });
console.log('Users:', users);

// Updating a record
db.update('users', { age: 31 }, { name: 'Alice' });

// Deleting a record
db.delete('users', { name: 'Alice' });

console.log('Done.');