mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 21:59:40 +00:00
feat: working on saving goals jounrey for juniors
This commit is contained in:
41
src/saving-goals/entities/category.entity.ts
Normal file
41
src/saving-goals/entities/category.entity.ts
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user