Skip to main content

Function: PrimaryKey()

PrimaryKey(options?): PropertyDecorator

Defined in: src/decorators/PrimaryKey.ts:18

Property decorator designating a property as the primary key of the entity.

Parameters​

ParameterTypeDescription
options?PrimaryKeyOptionsConfiguration options such as autoIncrement.

Returns​

PropertyDecorator

Usecase​

Designate unique record identifiers for find(), update(), remove(), and relation joins.

Example​

@PrimaryKey({ autoIncrement: true })
id!: number;