Why do I need to define the cascade option in the entity which is in relation to the cascaded entity and not in the original entity in itself?
For example:
@Entity()
export class Category {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@ManyToMany((type) => Question, (question) => question.categories)
questions: Question[]
}
This is an entity named Category Followed by the entity it is in relation with, named Question.
@Entity()
export class Question {
@PrimaryGeneratedColumn()
id: number
@Column()
title: string
@Column()
text: string
@ManyToMany((type) => Category, (category) => category.questions, {
cascade: true,
})
@JoinTable()
categories: Category[]
}
Why am I defining the cascade option in the Question entity and not in the Category entity?