42 lines
754 B
TypeScript
42 lines
754 B
TypeScript
|
import {
|
||
|
Column,
|
||
|
CreateDateColumn,
|
||
|
Entity,
|
||
|
ManyToOne,
|
||
|
PrimaryGeneratedColumn,
|
||
|
UpdateDateColumn,
|
||
|
} from 'typeorm';
|
||
|
import { User } from '../user/user.entity';
|
||
|
|
||
|
@Entity()
|
||
|
export class Upload {
|
||
|
@PrimaryGeneratedColumn()
|
||
|
id: number;
|
||
|
|
||
|
@Column({ nullable: false })
|
||
|
original_name: string;
|
||
|
|
||
|
@Column({ nullable: false })
|
||
|
file: string;
|
||
|
|
||
|
@ManyToOne(() => User, {
|
||
|
nullable: true,
|
||
|
onDelete: 'SET NULL',
|
||
|
onUpdate: 'CASCADE',
|
||
|
})
|
||
|
uploader: User;
|
||
|
|
||
|
@CreateDateColumn({
|
||
|
type: 'timestamp',
|
||
|
default: () => 'CURRENT_TIMESTAMP(6)',
|
||
|
})
|
||
|
public created_at: Date;
|
||
|
|
||
|
@UpdateDateColumn({
|
||
|
type: 'timestamp',
|
||
|
default: () => 'CURRENT_TIMESTAMP(6)',
|
||
|
onUpdate: 'CURRENT_TIMESTAMP(6)',
|
||
|
})
|
||
|
public updated_at: Date;
|
||
|
}
|