Registry / database / woowahan-orm

woowahan-orm

JSON →
library2.0.1jsnpmunverified

WoowahanORM is a light promise-based Node.js ORM for MySQL, providing simple Model queries (INSERT, UPDATE, SELECT, DELETE), type validations, and automatic table synchronization for migration. Currently at version 2.0.1, it follows Semantic Versioning. It requires mysql2 as a peer dependency. Unlike heavier ORMs like Sequelize or TypeORM, it emphasizes minimalism and straightforward CRUD operations with built-in validation and default fields (id, createdAt, updatedAt, isDeleted). It supports common DataTypes and filters out unspecified attributes.

npm install woowahan-orm
INSTALL
IMPORT
SIG · WOOWAHAN-ORM
W
woowahan-orm
databasejavascriptv2.0.1
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.

default
const woowahanORM = require('woowahan-orm')
CommonJS require is the primary import method; no ESM export available.
Model
const { Model } = require('woowahan-orm')
import { Model } from 'woowahan-orm'
Package does not provide ESM exports; destructure from require.
DataTypes
const { DataTypes } = require('woowahan-orm')
const DataTypes = require('woowahan-orm').DataTypes
DataTypes is exported as a named export; destructure from require.

Connects to MySQL, defines a Product model with validation, creates a record, and queries all records.

const woowahanORM = require('woowahan-orm') const { Model, DataTypes } = woowahanORM const db = woowahanORM({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'test' }, { sync: { force: false } }) class Product extends Model { static init() { return super.init({ name: { dataType: DataTypes.STRING, required: true }, price: { dataType: DataTypes.INTEGER, defaultValue: 0 } }) } } async function main() { const product = await Product.create({ name: 'Widget', price: 10 }) console.log('Created:', product.id) const products = await Product.findAll() console.log('Products:', products.length) } main().catch(console.error)
Debug
Known issues
gotchaThe package does not support ESM (import) syntax. Use CommonJS require() only.
fix
Replace import statements with const { Model, DataTypes } = require('woowahan-orm')
affects: >=2.0.0
gotchamysql2 is a required peer dependency and must be installed separately.
fix
Run 'npm install mysql2' alongside woowahan-ORM
affects: >=2.0.0
deprecatedThe sync option with force: true will drop and recreate tables, causing data loss. Deprecated pattern for production.
fix
Use sync: { force: false } for development and manage migrations manually.
affects: >=1.0.0
gotchaAuto-generated fields id, createdAt, updatedAt, isDeleted are always added; do not define them manually.
fix
Omit these fields from your model attributes.
affects: >=1.0.0
gotchaValidation throws a 400 error for incorrect types, but unspecified attributes are silently ignored.
fix
Ensure all input attributes are defined in the model to avoid silent filtering.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'mysql2'
Missing required peer dependency mysql2
fix
npm install mysql2
TypeError: woowahanORM is not a function
Incorrect import style (ESM import instead of require)
fix
Use const woowahanORM = require('woowahan-orm')
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Attempting to use ESM import on a CJS-only package
fix
Switch to require() syntax or configure your project to use CommonJS
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
mysql2requiredPeer dependency for MySQL database connectivity
Agent activity
21 hits · last 30 days
node
16
Meta
2
OpenAI (training)
1
Resources
woowahan-orm — npm install woowahan-orm · libregistry