Documentation / @zerotal/orm / index / table
Function: table()
table(
tableName,options?):TableDecoratorBuilder
Defined in: packages/orm/src/model/decorators/table.ts:88
Fluent class decorator factory for configuring a BaseModel subclass.
Accepts an optional options object as a second argument so you don't need to
chain methods if you prefer the inline form. Both styles are fully equivalent.
// Style A — fluent chain
@table("users").withoutTimestamps()
export class User extends BaseModel { ... }
// Style B — options object
@table("users", { timestamps: true })
export class User extends BaseModel { ... }
Timestamps are on by default — use .withoutTimestamps() to opt out. Soft
deletes are opt-in via the SoftDeletes mixin: extends BaseModelWith(SoftDeletes).
@table is the single, required way to configure a model: besides setting the
table name and options, it anchors the class's @column/relation registrations at
definition time (the decorator runs synchronously with the class in hand). Any class
that declares column or relation fields — including a subclass that ADDS fields — must
carry its own @table, or those fields won't register.
Parameters
tableName
string
options?
TableOptions = {}