35 lines
784 B
TypeScript
35 lines
784 B
TypeScript
import { Column, Entity, JoinTable, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { Tag } from '../../tags/entities/tag.entity';
|
|
import { Category } from '../../categories/entities/category.entity';
|
|
import { Merchant } from '../../merchants/entities/merchant.entity';
|
|
|
|
@Entity()
|
|
export class Expense {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column()
|
|
year: string;
|
|
|
|
@Column()
|
|
month: string;
|
|
|
|
@Column()
|
|
day: string;
|
|
|
|
@Column()
|
|
cents: number;
|
|
|
|
@ManyToOne(() => Category, { eager: true })
|
|
category: Category;
|
|
|
|
@Column({ nullable: true })
|
|
note: string;
|
|
|
|
@ManyToOne(() => Merchant, { nullable: true, eager: true })
|
|
merchant: Merchant;
|
|
|
|
@ManyToMany(() => Tag, { nullable: true, eager: true })
|
|
@JoinTable()
|
|
tags: Tag[];
|
|
}
|