forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem.entity.ts
More file actions
42 lines (30 loc) · 1.04 KB
/
Copy pathitem.entity.ts
File metadata and controls
42 lines (30 loc) · 1.04 KB
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
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { Split } from './split.entity';
const jsonColumnType = process.env.NODE_ENV === 'test' ? 'simple-json' : 'jsonb';
const jsonArrayDefault = process.env.NODE_ENV === 'test' ? '[]' : [];
@Entity('items')
export class Item {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ type: 'uuid' })
splitId!: string;
@Column({ type: 'varchar' })
name!: string;
@Column({ type: 'integer' })
quantity!: number;
@Column({ type: 'decimal', precision: 10, scale: 2 })
unitPrice!: number;
@Column({ type: 'decimal', precision: 10, scale: 2 })
totalPrice!: number;
@Column({ type: 'varchar', nullable: true })
category?: string;
@Column({ type: jsonColumnType, default: jsonArrayDefault })
assignedToIds!: string[];
@CreateDateColumn()
createdAt!: Date;
@UpdateDateColumn()
updatedAt!: Date;
@ManyToOne(() => Split, (split) => split.items)
@JoinColumn({ name: 'splitId' })
split?: Split;
}