File size: 1,098 Bytes
1e3bf12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';
import { Supplier } from './supplier.entity';
import { Category } from './category.entity';

@Entity('Products')
export class Product {
  @PrimaryGeneratedColumn()
  ProductID: number;

  @Column({ length: 40 })
  ProductName: string;

  @ManyToOne(() => Supplier)
  @JoinColumn({ name: 'SupplierID' })
  Supplier: Supplier;

  @ManyToOne(() => Category)
  @JoinColumn({ name: 'CategoryID' })
  Category: Category;

  @Column({ length: 20, nullable: true })
  QuantityPerUnit: string;

  @Column('decimal', { precision: 18, scale: 2, nullable: true })
  UnitPrice: number;

  @Column({ type: 'smallint', nullable: true })
  UnitsInStock: number;

  @Column({ type: 'smallint', nullable: true })
  UnitsOnOrder: number;

  @Column({ type: 'smallint', nullable: true })
  ReorderLevel: number;

  @Column()
  Discontinued: boolean;

  @CreateDateColumn({ type: 'timestamp' })
  createdAt: Date;

  @UpdateDateColumn({ type: 'timestamp' })
  updatedAt: Date;
}