Files
private_image/backend/src/modules/upload/entities/Upload.ts
T

44 lines
1.1 KiB
TypeScript

import { Column, CreateDateColumn, Entity, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { UploadMode } from '../types/UploadMode';
import { UploadHotlink } from './UploadHotlink';
import { UploadZk } from './UploadZk';
@Entity('uploads')
export class Upload {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ type: 'enum', enum: UploadMode })
mode: UploadMode;
@Column({ type: 'text' })
storagePath: string;
@Column({ type: 'bytea' })
iv: Buffer;
@Column({ type: 'int', nullable: true })
maxViews: number | null;
@Column({ type: 'int', default: 0 })
viewCount: number;
@Column()
deleteTokenHash: string;
@OneToOne(() => UploadZk, zk => zk.upload)
zk: UploadZk | null;
@OneToOne(() => UploadHotlink, hotlink => hotlink.upload)
hotlink: UploadHotlink | null;
@Column({ type: 'timestamptz', nullable: true })
lastViewedAt: Date | null;
@Column({ type: 'timestamptz', nullable: true })
expiresAt: Date | null;
@CreateDateColumn({ type: 'timestamptz' })
createdAt: Date;
}