Files
zod-backend/src/guardian/entities/guradian.entity.ts
Abdalhamid Alhamad 5e9e83cb74 feat: gift journeys
2024-12-22 16:34:02 +03:00

52 lines
1.4 KiB
TypeScript

import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
JoinColumn,
OneToMany,
OneToOne,
PrimaryColumn,
UpdateDateColumn,
} from 'typeorm';
import { Allowance } from '~/allowance/entities';
import { Customer } from '~/customer/entities';
import { Gift } from '~/gift/entities';
import { Junior } from '~/junior/entities';
import { MoneyRequest } from '~/money-request/entities';
import { Task } from '~/task/entities';
@Entity('guardians')
export class Guardian extends BaseEntity {
@PrimaryColumn('uuid')
id!: string;
@Column('uuid', { name: 'customer_id' })
customerId!: string;
@OneToOne(() => Customer, (customer) => customer.guardian, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'customer_id' })
customer!: Customer;
@OneToMany(() => Junior, (junior) => junior.guardian)
juniors!: Junior[];
@OneToMany(() => Task, (task) => task.assignedBy)
tasks?: Task[];
@OneToMany(() => MoneyRequest, (moneyRequest) => moneyRequest.reviewer)
moneyRequests?: MoneyRequest[];
@OneToMany(() => Allowance, (allowance) => allowance.guardian)
allowances?: Allowance[];
@OneToMany(() => Gift, (gift) => gift.giver)
gifts?: Gift[];
@CreateDateColumn({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
updatedAt!: Date;
}