-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatUser.ts
75 lines (57 loc) · 1.32 KB
/
ChatUser.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {
Entity,
Column,
Unique,
CreateDateColumn,
UpdateDateColumn,
OneToMany,
ManyToOne,
PrimaryGeneratedColumn,
ManyToMany,
JoinTable,
} from "typeorm";
import { Role, Status, Group, Message, Session } from ".";
@Entity()
@Unique(["email"])
@Unique(["username"])
@Unique(["uuid"])
export class ChatUser {
@PrimaryGeneratedColumn("uuid")
uuid?: string;
@Column()
username: string;
@Column()
email: string;
@Column()
firstName: string;
@Column()
lastName: string;
@Column({ default: false })
verified: boolean;
@Column({ nullable: true })
verifiedAt: Date;
@Column()
password: string;
@Column({ nullable: true })
image: string;
@Column({ nullable: true })
phone: string;
@ManyToOne(() => Status, (status) => status.users)
status: Status;
@ManyToOne(() => Role, (role) => role.users)
role: Role;
@OneToMany(() => ChatUser, (friend) => friend.friends, { nullable: true })
friends?: ChatUser[];
@OneToMany(() => Session, (session) => session.user, { nullable: true })
sessions?: Session[];
@ManyToMany(() => Group, (group) => group.users, { nullable: true })
groups?: Group[];
@OneToMany(() => Message, (msg) => msg.users, {
nullable: true,
})
messages?: Message[];
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}