feat: working on saving goals jounrey for juniors

This commit is contained in:
Abdalhamid Alhamad
2024-12-15 12:44:59 +03:00
parent 24d990592d
commit 4d2f6f57f4
35 changed files with 754 additions and 2 deletions

View File

@ -0,0 +1,41 @@
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToMany,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Junior } from '~/junior/entities';
import { CategoryType } from '../enums';
import { SavingGoal } from './saving-goal.entity';
@Entity('categories')
export class Category {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ type: 'varchar', length: 255, name: 'name' })
name!: string;
@Column({ type: 'varchar', length: 255, name: 'type' })
type!: CategoryType;
@Column({ type: 'uuid', name: 'junior_id', nullable: true })
juniorId!: string;
@ManyToOne(() => Junior, (junior) => junior.categories, { onDelete: 'CASCADE', nullable: true })
@JoinColumn({ name: 'junior_id' })
junior!: Junior;
@ManyToMany(() => SavingGoal, (savingGoal) => savingGoal.categories)
goals!: SavingGoal[];
@CreateDateColumn({ type: 'timestamp', name: 'created_at', default: () => 'CURRENT_TIMESTAMP' })
createdAt!: Date;
@UpdateDateColumn({ type: 'timestamp', name: 'updated_at', default: () => 'CURRENT_TIMESTAMP' })
updatedAt!: Date;
}