[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/orm](../../README) / [index](../README) / table

# Function: table()

> **table**(`tableName`, `options?`): [`TableDecoratorBuilder`](../interfaces/TableDecoratorBuilder)

Defined in: [packages/orm/src/model/decorators/table.ts:88](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/orm/src/model/decorators/table.ts#L88)

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.

```ts
// 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`](../interfaces/TableOptions) = `{}`

## Returns

[`TableDecoratorBuilder`](../interfaces/TableDecoratorBuilder)
