tekir
All Packages
Decoratorsv0.1.3

@tekir/db-decorators

@hidden, @cast, @HasMany, @BelongsTo, @BeforeSave.

Installation

$bun add @tekir/db-decorators

Features

  • @table, @timestamps, @softDeletes class decorators
  • @hidden and @fillable field decorators
  • @cast for type coercion (boolean, json, date, etc.)
  • @HasOne, @HasMany, @BelongsTo, @ManyToMany relationships
  • @BeforeSave, @AfterCreate, and 14 total lifecycle hooks

Quick Example

TypeScript
import { table, hidden, cast, HasMany, BeforeSave } from '@tekir/db-decorators'

@table('users')
class User extends BaseModel {
  @hidden() declare password: string
  @cast('boolean') declare isActive: boolean
  @HasMany(() => Post) declare posts: Post[]
}

Changelog

v0.1.3LatestSeptember 16, 2026
  • Published output now uses the shared Node-targeted ESM bundle pipeline with external dependencies and generated TypeScript declarations, while Bun consumers keep the native source export.
v0.1.2July 23, 2026
  • Package metadata now follows the shared compatible 0.1.x dependency range used by this coordinated Tekir release.
v0.1.1June 13, 2026
  • Field decorators (@hidden, @fillable, @cast, relations) and lifecycle hooks now build their own collection per class and inherit a copy of the parent's, so adding fields or hooks on a subclass no longer mutates the parent class. This keeps the mass-assignment boundary (@hidden/@fillable) correct across inheritance.
  • Found and fixed with Fable.
v0.1.0April 1, 2026
  • Initial release

Other Decorators packages