'Call function at onDelete with TypeORM NestJs

Considering a many-to-many typeORM relation like :

@ManyToOne(() => ColType, targetTable => targetTable.myTable, {onDelete: "CASCADE"})
@JoinColumn({name: 'varId'})
var: ColType;
@Column({nullable: true})
varId: number;

Is there any way to call a function when TypeORM detect a deletion triggered by the cascade. Something like :

@ManyToOne(() => ColType, targetTable => targetTable.myTable, {onDelete: "CASCADE", onDeleteCallFunction: "MyFunction"})

In my case the table isntance store a data that I want to proceed if the table instance is deleted.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source