#TypeOrm extend class

7 messages · Page 1 of 1 (latest)

lost lark
#

so, I have an abstract class called Quantity, it looks like this:

export abstract class Quantity {
  @Column({ default: 0 })
  totalQuantity: number;

  @Column({ default: 0 })
  availableQuantity: number;
}

And I'm trying to use it on my Equipment entity by extending it:

@Entity()
export class Equipment extends Quantity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  type: string;

  @Column()
  model: string;

  @Column()
  hardware: string;

  @OneToMany(() => EquipmentItem, item => item.equipment)
  items: EquipmentItem[];

  @ManyToOne(() => Chip, item => item.equipments)
  chip: Chip;
}

But the quantity fields aren't being shown, is there anything more I gotta do?

lapis summit
#

Try to decorate Quantity with @Entity ?

#

or remove abstract maybe

lost lark
#

but I will try

#

oh, no, won't even try actually

#

doesn't make sense decorating with @Entity