Registry / database / orm-alpha

orm-alpha

JSON →
library1.2.18jsnpmunverified

Alpha ORM is a zero-configuration JavaScript ORM that automatically creates tables and columns, supporting MySQL, SQLite, and PostgreSQL. Version 1.2.18 is the latest stable release. Unlike traditional ORMs that require schema definitions and migrations, Alpha ORM dynamically infers the schema from usage, allowing developers to create, read, update, and delete records without any setup beyond database connection. It is designed for rapid prototyping and simple applications where schema flexibility is paramount, sacrificing type safety and explicit schema control for ease of use. The package is published on npm as 'orm-alpha' with minimal dependencies.

npm install orm-alpha
INSTALL
IMPORT
SIG · ORM-ALPHA
O
orm-alpha
databasejavascriptv1.2.18
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AlphaORM
const { AlphaORM } = require('alpha-orm')
import { AlphaORM } from 'alpha-orm'
Package is CommonJS only. No ESM exports. Use require.
AlphaORM (destructured as DB)
const { AlphaORM: DB } = require('alpha-orm')
import AlphaORM from 'alpha-orm'
Common pattern is to rename to DB for brevity. No default export.
AlphaORM (as default, incorrect)
const { AlphaORM } = require('alpha-orm')
const AlphaORM = require('alpha-orm')
Do not assign require result directly; AlphaORM is a named export, not default.

Demonstrates setup with SQLite, creating a record, reading all, finding by condition, and updating.

const { AlphaORM: DB } = require('alpha-orm'); // Setup SQLite (no config required) DB.setup('sqlite', { database: 'test.db' }); (async () => { // Create a record const product = await DB.create('product'); product.name = 'Running shoes'; product.price = 5000; await DB.store(product); // Read all products const products = await DB.getAll('product'); console.log('Products:', products); // Find by condition const found = await DB.find('product', 'name = :name', { name: 'Running shoes' }); console.log('Found:', found); // Update found.price = 4500; await DB.store(found); // Delete // await DB.drop(found); })();
Debug
Known issues
gotchaTable and column schemas are auto-generated on the fly; typos in field names create new columns. This can lead to unexpected database schema drift.
fix
Always verify field names and ensure consistency across operations.
affects: >=0.0.0
gotchaNo built-in migration or version control; database schema evolves implicitly. Loss of context can break existing queries if field names change.
fix
Consider using with a dedicated migration tool or lock your schema with explicit table creation.
affects: >=0.0.0
gotchaThe package uses CommonJS only; attempts to import via ES6 import will fail.
fix
Use require() instead of import.
affects: >=0.0.0
gotchaThe database drivers (mysql, sqlite3, pg) are not included; you must install them separately. Without the driver, DB.setup throws.
fix
Install the required driver: npm install mysql or sqlite3 or pg.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql'
MySQL driver not installed locally.
fix
npm install mysql
TypeError: DB.setup is not a function
Importing the package incorrectly; likely using default import instead of named destructuring.
fix
Use const { AlphaORM: DB } = require('alpha-orm');
Error: getaddrinfo ENOTFOUND localhost
Database server not running or hostname incorrect (used with MySQL/PostgreSQL).
fix
Ensure database server is running and host is correct.
Upgrade
Version history
1.2.18latest on npm
Audit
Dependencies
mysqloptionalMySQL database driver when using MySQL
sqlite3optionalSQLite database driver when using SQLite
pgoptionalPostgreSQL database driver when using PostgreSQL
Agent activity
7 hits · last 30 days
node
6
Resources
orm-alpha — npm install orm-alpha · libregistry