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

57 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-03-09 18:37:04 +00:00
import {
Column,
CreateDateColumn,
Entity,
2022-04-15 19:00:02 +00:00
JoinTable,
ManyToMany,
2022-03-16 18:37:50 +00:00
ManyToOne,
2022-03-09 18:37:04 +00:00
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
2022-04-15 19:00:02 +00:00
import { Privilege } from '../privilege/privilege.entity';
2022-03-09 18:37:04 +00:00
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;
2022-08-26 14:14:40 +00:00
@CreateDateColumn()
2022-03-09 18:37:04 +00:00
public created_at: Date;
2022-08-26 14:14:40 +00:00
@UpdateDateColumn()
2022-03-09 18:37:04 +00:00
public updated_at: Date;
2022-03-16 18:37:50 +00:00
@ManyToOne(() => Upload, {
2022-03-09 18:37:04 +00:00
nullable: true,
onDelete: 'SET NULL',
onUpdate: 'CASCADE',
})
public picture: Upload;
2022-04-15 19:00:02 +00:00
@ManyToMany(() => Privilege)
@JoinTable()
public privileges: Privilege[];
2022-03-09 18:37:04 +00:00
}