There is an amazing way to reduce duplication in your app (using composition over inheritance) by using embedded columns. Embedded column is a column which accepts a class with its own columns and merges those columns into the current entity's database table. Example:
Let's say we have User, Employee and Student entities. All those entities have few things in common - first name and last name properties
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: string
@Column()
firstName: string
@Column()
lastName: string
@Column()
isActive: boolean
}
This way code duplication in the entity classes is reduced. You can use as many columns (or relations) in embedded classes as you need. You even can have nested embedded columns inside embedded classes.