first commit
This commit is contained in:
27
api/src/entities/Category.ts
Normal file
27
api/src/entities/Category.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { Expense } from './Expense.js';
|
||||
import { User } from './User.js';
|
||||
|
||||
@Entity('categories')
|
||||
export class Category {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 80 })
|
||||
name!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 32, default: '#0d6efd' })
|
||||
color!: string;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
isSystem!: boolean;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
createdAt!: Date;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.categories, { nullable: true, onDelete: 'CASCADE' })
|
||||
user!: User | null;
|
||||
|
||||
@OneToMany(() => Expense, (expense) => expense.category)
|
||||
expenses!: Expense[];
|
||||
}
|
||||
Reference in New Issue
Block a user