Skip to content

v1.4.0 Release

Choose a tag to compare

@velkymx velkymx released this 09 Apr 22:21
· 194 commits to main since this 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 users

This will connect to your database using your .env settings and output a file called:

users.json

Features:

  • Maps MySQL types to ts-orm types (string, number, uuid, boolean, enum, date, datetime)
  • Detects auto_increment fields and marks them correctly
  • Extracts enum values as arrays
  • Assigns proper length limits for fields like varchar, date, and datetime
  • Skips optional or null defaults appropriately

Examples

MySQL column:

id INT AUTO_INCREMENT PRIMARY KEY

Generates:

{
  "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 users

This is especially useful when onboarding legacy tables or rapidly scaffolding new endpoints.


Thanks for using ts-orm. Feedback and feature suggestions welcome!