mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 05:42:27 +00:00
77 lines
2.2 KiB
TypeScript
77 lines
2.2 KiB
TypeScript
import {
|
|
Column,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
OneToMany,
|
|
OneToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Customer } from '~/customer/entities';
|
|
import { Gift } from '~/gift/entities';
|
|
import { Theme } from '~/junior/entities';
|
|
import { SavingGoal } from '~/saving-goals/entities';
|
|
import { Task } from '~/task/entities';
|
|
import { TaskSubmission } from '~/task/entities/task-submissions.entity';
|
|
import { User } from '~/user/entities';
|
|
import { DocumentType, UploadStatus } from '../enums';
|
|
|
|
@Entity('documents')
|
|
export class Document {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ type: 'varchar', length: 255, default: UploadStatus.NOT_UPLOADED, name: 'upload_status' })
|
|
uploadStatus!: UploadStatus;
|
|
|
|
@Column({ type: 'varchar', length: 255 })
|
|
name!: string;
|
|
|
|
@Column({ type: 'varchar', length: 255 })
|
|
extension!: string;
|
|
|
|
@Column({ type: 'varchar', length: 255, name: 'document_type' })
|
|
documentType!: DocumentType;
|
|
|
|
@Column({ type: 'uuid', nullable: true, name: 'created_by_id' })
|
|
createdById!: string;
|
|
|
|
@OneToOne(() => User, (user) => user.profilePicture, { onDelete: 'SET NULL' })
|
|
userPicture?: Customer;
|
|
|
|
@OneToOne(() => Customer, (customer) => customer.civilIdFront, { onDelete: 'SET NULL' })
|
|
customerCivilIdFront?: User;
|
|
|
|
@OneToOne(() => Customer, (customer) => customer.civilIdBack, { onDelete: 'SET NULL' })
|
|
customerCivilIdBack?: User;
|
|
|
|
@OneToMany(() => Theme, (theme) => theme.avatar)
|
|
themes?: Theme[];
|
|
|
|
@OneToMany(() => Task, (task) => task.image)
|
|
tasks?: Task[];
|
|
|
|
@OneToMany(() => TaskSubmission, (taskSubmission) => taskSubmission.proofOfCompletion)
|
|
submissions?: TaskSubmission[];
|
|
|
|
@OneToMany(() => SavingGoal, (savingGoal) => savingGoal.image)
|
|
goals?: SavingGoal[];
|
|
|
|
@OneToMany(() => Gift, (gift) => gift.image)
|
|
gifts?: Gift[];
|
|
|
|
@ManyToOne(() => User, (user) => user.createdDocuments, { nullable: true, onDelete: 'SET NULL' })
|
|
@JoinColumn({ name: 'created_by_id' })
|
|
createdBy?: User;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date;
|
|
|
|
@Column({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
|
|
// virtual field
|
|
url?: string;
|
|
}
|