Skip to content

v0.2.0

Choose a tag to compare

@wrsouza wrsouza released this 08 Jun 02:02
· 20 commits to main since this release

What's Changed

Centralised configuration — createConnection()

  • New createConnection(config: OrionConfig) as the single entry point — bootstraps connection, morph map and lazy-loading guard in one call
  • Accepts connection as a URL string or a full config object
  • CLI auto-detects src/database.ts, database.ts, src/orion.ts in addition to legacy orion.config.* files
  • --config <path> flag for non-standard locations

CLI improvements

  • CLI auto-registers ts-node from the project's node_modulesnpx orion migrate works without wrapper scripts
  • db:seed [--class=Name] — run seeders (falls back to alphabetical order when no DatabaseSeeder is found)
  • make:seed <name> — scaffold a seeder file
  • make:factory <name> — scaffold a factory file

Seeds

  • Seeder abstract base class with run() and call([...seeders]) for chaining
  • Seeder and factory paths derived from the migrations path (same src/database/ base)

@map('column_name') decorator

  • Maps a model property to a different DB column name (camelCase ↔ snake_case)
  • Transparent read/write, where/orderBy/groupBy, serialization and dirty tracking all use the property name

.primary() column modifier

  • Fluent inline PRIMARY KEY on any column: table.uuid('id').primary()
  • Supported in all five grammar dialects

foreignId / foreignUuid fluent FK chaining

  • Both methods now create the column and return a ForeignKeyDefinition for chaining:
    table.foreignUuid('user_id').references('id').on('users').onDelete('CASCADE')

Model.with() static shortcut

  • User.with('posts').get() works directly
  • ModelBuilder.first() now applies eager loads (previously only get() did)

Migration transactions

  • Each up() and down() runs inside a database transaction — partial failures are fully rolled back

Bug fixes

  • ModelSubclass index signature removed — no more ts(2684) in strict TypeScript
  • OrmConfig in CLI now supports all five drivers (previously only postgres)
  • make:migration templates now import from @wrsouza/orion (was orion)
  • Husky hooks fixed for Windows (missing #!/bin/sh shebang)

Breaking changes

  • optionalDependencies replaced by peerDependencies + peerDependenciesMeta — install only the driver you need: npm install pg