mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-10-23 18:07:56 +00:00
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import {
|
|
Column,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
OneToMany,
|
|
OneToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Customer } from '~/customer/entities';
|
|
import { Theme } from '~/junior/entities';
|
|
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;
|
|
|
|
@OneToMany(() => Theme, (theme) => theme.avatar)
|
|
themes?: Theme[];
|
|
|
|
@ManyToOne(() => User, (user) => user.createdDocuments, { nullable: true, onDelete: 'SET NULL' })
|
|
@JoinColumn({ name: 'created_by_id' })
|
|
createdBy?: User;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date;
|
|
|
|
@Column({ name: 'created_at', type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
|
|
// virtual field
|
|
url?: string;
|
|
}
|