ZenORM is a Node.js ORM framework that auto-generates TypeScript declarations from an existing MySQL database schema. Unlike traditional ORMs that create database structures, it works inversely by generating model code based on the actual table definitions, making it ideal for retrofitting ORM support into existing projects. It is designed with multi-tenant SAAS systems in mind, supporting multiple database servers and databases, but also works for monoliths. Version 4.6.1 is the latest stable release. Key differentiators include a powerful AB query tool for complex queries, decoration-based model relationships (Join, Many), and automatic TypeScript type generation. Requires mysql-easy-query for runtime and @zenorm/generate for code generation.
npm install zenormNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows complete setup: installing deps, generating models, configuring database pool, and performing CRUD operations (create, read, update, query, pagination).
Ensure your MySQL database has the expected tables before generating models.
Create separate pool configuration in your application entry point using createPoolCompatible.
For circular refs: import the module as a namespace and use ProfileRef in the decorator, not the direct import.
npm install zenorm
Add to tsconfig.json: "experimentalDecorators": true, "emitDecoratorMetadata": true
Ensure you run 'npm run dbgen' first, then import from the generated './model' directory (e.g., import { Repositories } from './model').