Repository navigation
v1.4.0 Release
This release introduces a powerful new command-line tool that allows you to generate ts-orm JSON structs directly from your MySQL tables. It's the fastest way to bootstrap your project with real schema definitions.
New: CLI Struct Generator
You can now generate a ts-orm compatible struct with a single command:
npx ts-orm struct usersThis will connect to your database using your .env settings and output a file called:
users.json
Features:
- Maps MySQL types to
ts-ormtypes (string,number,uuid,boolean,enum,date,datetime) - Detects
auto_incrementfields and marks them correctly - Extracts enum values as arrays
- Assigns proper length limits for fields like
varchar,date, anddatetime - Skips optional or null defaults appropriately
Examples
MySQL column:
id INT AUTO_INCREMENT PRIMARY KEYGenerates:
{
"name": "id",
"type": "number",
"required": true,
"length": 11,
"default": "auto_increment"
}MySQL enum:
status ENUM('draft', 'published') NOT NULL DEFAULT 'draft'Generates:
{
"name": "status",
"type": "enum",
"required": true,
"length": null,
"default": "draft",
"enum": ["draft", "published"]
}Getting Started
npm install @velkymx/ts-orm
npx ts-orm struct usersThis is especially useful when onboarding legacy tables or rapidly scaffolding new endpoints.
Thanks for using ts-orm. Feedback and feature suggestions welcome!