mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 20:51:44 +00:00
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import {
|
|
BaseEntity,
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
OneToMany,
|
|
OneToOne,
|
|
PrimaryColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Customer } from '~/customer/entities';
|
|
import { Junior } from '~/junior/entities';
|
|
import { AllowanceSchedule } from '~/allowance/entities/allowance-schedule.entity';
|
|
import { MoneyRequest } from '~/money-request/entities/money-request.entity';
|
|
|
|
@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(() => MoneyRequest, (moneyRequest) => moneyRequest.guardian)
|
|
moneyRequests!: MoneyRequest[];
|
|
|
|
@OneToMany(() => AllowanceSchedule, (schedule) => schedule.guardian)
|
|
allowanceSchedules!: AllowanceSchedule[];
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date;
|
|
}
|