I'm in a project for which there is already a defined database, and I need to transform this data into entities in the application layer.
There are these tables:
These two tables technically represent just one entity, and I wouldn't want to subclass the normal TypeORM link to these joins.
I would like to have something like this:
Obs: Have entity attributes referring to columns from another table
@Entity({name: "MAIN_order"})
export class Order {
@Column({name: "number"})
public num: number;
@Column({name: "res_code"})
public resCode: string;
/*
Many-to-many for order users (ignore)
public users: User[];
*/
@Column()
public open: boolean;
@Column({name: "date_start"})
public dateStart: Date;
@Column({name: "date_end"})
public dateEnd: Date;
@Column()
public obs: string;
@Column()
public origin: boolean;
/* ======== ANOTHES TABLE (MAIN_corre_order) ======== */
/*
one-to-many for order issues (ignore)
public issues: string[];
*/
@Column()
public detail: string;
@Column()
public cause: string;
@Column()
public action: string;
@Column({name: "type_code"})
public type: string;
}
Is there a way to do this in TypeORM? How ?