-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.entity.ts
50 lines (42 loc) · 1.08 KB
/
user.entity.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Entity, Column, OneToMany } from 'typeorm';
import { Base } from '../../entities/base.entity';
import { Project } from '../projects/project.entity';
import { Task } from '../tasks/task.entity';
import { IsNotEmpty, IsEmail, IsIn } from 'class-validator';
import { Exclude } from 'class-transformer';
@Entity('users')
export class User extends Base {
@Column({ unique: true })
@IsNotEmpty()
username: string;
@Column({ unique: true })
@IsNotEmpty()
@IsEmail()
email: string;
@Column()
@IsNotEmpty()
@Exclude()
password: string;
@Column()
@IsNotEmpty()
@Exclude()
refreshToken: string;
@Column({ default: 'active' })
@IsNotEmpty()
@IsIn(['active', 'deactive'])
status: 'active' | 'deactive';
@OneToMany(() => Project, (project) => project.user)
projects: Project[];
@OneToMany(() => Task, (task) => task.user)
tasks: Task[];
get serialize() {
return {
uuid: this.uuid,
username: this.username,
email: this.email,
status: this.status,
createdAt: this.createdAt,
updatedAt: this.updatedAt,
};
}
}