eager: boolean- If set to true, the relation will always be loaded with the main entity when using
QueryBuilderon this entity
onDelete: "RESTRICT"|"CASCADE"|"SET NULL"- specifies how foreign key should behave when referenced object is deleted
primary: boolean- Indicates whether this relation's column will be a primary column or not.
nullable: boolean- Indicates whether this relation's column is nullable or not. By default it is nullable.
orphanedRowAction: "nullify" | "delete" | "soft-delete"- When a child row is removed from its parent, determines if the child row should be orphaned (default) or deleted (delete or soft delete).
category2. They will be automatically inserted, because we set
cascadeoption can be set as a
booleanor an array of cascade options
("insert" | "update" | "remove" | "soft-remove" | "recover").
false, meaning no cascades. Setting
cascade: truewill enable full cascades. You can also specify options by providing an array.
@JoinColumnnot only defines which side of the relation contains the join column with a foreign key, but also allows you to customize join column name and referenced column name.
@JoinColumn, it automatically creates a column in the database named
propertyName + referencedColumnName. For example:
categoryIdcolumn in the database. If you want to change this name in the database you can specify a custom join column name:
Categoryentity, instead of
id. Column name for that relation will become
@JoinTableis used for
many-to-manyrelations and describes join columns of the "junction" table. A junction table is a special separate table created automatically by TypeORM with columns that refer to the related entities. You can change column names inside junction tables and their referenced columns with
@JoinColumn: You can also change the name of the generated "junction" table.