Skip to main content

Function: Entity()

Entity(options?): ClassDecorator

Defined in: src/decorators/Table.ts:51

Class decorator marking a TypeScript class as a database entity managed by DbContext.

Parameters​

ParameterTypeDescription
options?string | EntityOptionsOptional entity configuration or table name string.

Returns​

ClassDecorator

Usecase​

Register a model class for ORM mapping, automated schema generation, and DbSet integration.

Example​

@Entity({ tableName: 'orders' })
export class Order {
@PrimaryKey()
id!: number;
}