icynet-auth-server/src/modules/objects/user/user.entity.ts

57 lines
1.1 KiB
TypeScript

import {
Column,
CreateDateColumn,
Entity,
OneToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
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({
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;
@OneToOne(() => Upload, {
nullable: true,
onDelete: 'SET NULL',
onUpdate: 'CASCADE',
})
public picture: Upload;
}