mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
52 lines
1.4 KiB
TypeScript
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;
|
|
}
|