57 lines
1.1 KiB
TypeScript
57 lines
1.1 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinTable,
|
|
ManyToMany,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Privilege } from '../privilege/privilege.entity';
|
|
import { Upload } from '../upload/upload.entity';
|
|
|
|
@Entity()
|
|
export class User {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column({ type: 'uuid', length: 36, nullable: false, unique: true })
|
|
uuid: string;
|
|
|
|
@Column({ length: 26, nullable: false, unique: true })
|
|
username: string;
|
|
|
|
@Column({ nullable: false, unique: true })
|
|
email: string;
|
|
|
|
@Column({ length: 32, nullable: false })
|
|
display_name: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
password: string;
|
|
|
|
@Column({ default: false })
|
|
activated: boolean;
|
|
|
|
@Column({ type: 'timestamp' })
|
|
public activity_at: Date;
|
|
|
|
@CreateDateColumn()
|
|
public created_at: Date;
|
|
|
|
@UpdateDateColumn()
|
|
public updated_at: Date;
|
|
|
|
@ManyToOne(() => Upload, {
|
|
nullable: true,
|
|
onDelete: 'SET NULL',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public picture: Upload;
|
|
|
|
@ManyToMany(() => Privilege)
|
|
@JoinTable()
|
|
public privileges: Privilege[];
|
|
}
|