Function: Computed()
Computed(
expression?):PropertyDecorator
Defined in: src/decorators/Computed.ts:20
Property decorator designating a database-computed / virtual column.
Computed columns are populated by SQL expressions or generated columns in the database.
They are automatically excluded from INSERT and UPDATE queries, but read during SELECT.
Parameters
| Parameter | Type | Description |
|---|---|---|
expression? | string | Optional SQL expression or description of how the column is computed. |
Returns
PropertyDecorator
Usecase
Map generated columns (e.g. GENERATED ALWAYS AS), full-text search tsvectors, or database formula columns.
Example
@Computed('LOWER(email)')
emailLower!: string;
@Computed('price * quantity')
lineTotal!: number;