Relations FAQ
How to create self referencing relation?
import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
OneToMany,
} from "typeorm"
@Entity()
export class Category {
@PrimaryGeneratedColumn()
id: number
@Column()
title: string
@Column()
text: string
@ManyToOne((type) => Category, (category) => category.childCategories)
parentCategory: Category
@OneToMany((type) => Category, (category) => category.parentCategory)
childCategories: Category[]
}How to use relation id without joining relation?
How to load relations in entities?
Avoid relation property initializers
Avoid foreign key constraint creation
Avoid circular import errors
Last updated