Function: ForeignKey()
ForeignKey(
referencedEntity,options?):PropertyDecorator
Defined in: src/decorators/PrimaryKey.ts:57
Property decorator defining an explicit foreign key column referencing another entity.
Parameters
| Parameter | Type | Description |
|---|---|---|
referencedEntity | () => Function | Lambda returning the referenced parent entity class. |
options? | ForeignKeyOptions | Column naming and referenced column settings. |
Returns
PropertyDecorator
Usecase
Link relational child entities to their parent entity tables.
Example
@ForeignKey(() => User)
userId!: number;