New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

eredbean

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eredbean

Lightweight ORM for Node.js with automatic table creation and CRUD operations

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

EredBean

EredBean is a lightweight ORM library for Node.js, similar to RedBeanPHP, with automatic table and field creation, full CRUD support, relationships, and versatility.

Installation

npm install eredbean

Supported Databases

  • MySQL
  • PostgreSQL
  • SQLite

Usage Example

import Bean from '@elv1bro/beanorm';

// MySQL/PostgreSQL
const mysqlConfig = {
  type: 'mysql',
  host: 'localhost',
  user: 'username',
  password: 'password',
  database: 'mydb'
};

// SQLite
const sqliteConfig = {
  type: 'sqlite',
  filename: './database.sqlite'
};

const user = new Bean('user', sqliteConfig);
user.set('name', 'Alice');
user.set('email', 'alice@example.com');
await user.save();

const user2 = await Bean.load('user', user._id);
user2.set('name', 'Alice Smith');
await user2.save();

await user2.delete();

🤖 AI Assistant Instructions

Project Metadata

We've prepared an automatically generated file PROJECT_METHODS.json with detailed information about methods and project structure.

How to Use Metadata

  • Examine the PROJECT_METHODS.json file in the project root
  • Pay attention to class methods:
    • BaseModel: Basic model operations
    • Bean: Main ORM class
    • Repository: Data repository management
    • TableMetadataCache: Table metadata caching
# Quick metadata view
cat PROJECT_METHODS.json

Generating Metadata

To update metadata, use the command:

npm run generate-ai-metadata

Key Classes and Their Methods

BaseModel

  • constructor(): Model initialization
  • set(): Setting field values
  • save(): Saving the model
  • delete(): Deleting the model
  • Static methods load() and find()

Bean

  • Extends BaseModel
  • Additional methods hasOne() and hasMany() for relationships
  • Support for working with different database adapters (MySQL, PostgreSQL, SQLite)

Repository

  • Low-level data operations
  • Methods create(), findById(), find(), deleteById()
  • Raw SQL query support

TableMetadataCache

  • Table structure caching
  • Methods getTableStructure(), setTableStructure()
  • Performance optimization

Code Study Recommendations

  • Start with Bean.js - the ORM's central class
  • Study BaseModel.js to understand basic logic
  • Analyze adapters in src/adapters/
  • Look at examples in the use/ directory

License

MIT License

Keywords

orm

FAQs

Package last updated on 21 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts