mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 05:42:27 +00:00
36 lines
921 B
TypeScript
36 lines
921 B
TypeScript
import {
|
|
BaseEntity,
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
OneToMany,
|
|
OneToOne,
|
|
PrimaryColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Customer } from '~/customer/entities';
|
|
import { Junior } from '~/junior/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[];
|
|
|
|
@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;
|
|
}
|