2021-11-23 16:04:12 -05:00
|
|
|
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
|
2022-03-30 17:18:16 -04:00
|
|
|
import { ChatRoom } from './chat_room.entity';
|
2021-11-23 16:04:12 -05:00
|
|
|
import { RefreshToken } from './refresh_token.entity';
|
2021-11-30 17:40:07 -05:00
|
|
|
import { UserRole } from './user_role.entity';
|
2021-11-16 21:14:46 -05:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class User {
|
2021-11-20 20:18:58 -05:00
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
id: number;
|
2021-11-16 21:14:46 -05:00
|
|
|
|
2021-11-20 20:18:58 -05:00
|
|
|
@Column({ unique: true, nullable: false })
|
|
|
|
email: string;
|
2021-11-16 21:14:46 -05:00
|
|
|
|
2021-11-20 20:18:58 -05:00
|
|
|
@Column({ nullable: false })
|
2021-12-03 20:31:24 -05:00
|
|
|
firstName: string;
|
|
|
|
|
|
|
|
@Column({ nullable: false })
|
|
|
|
lastName: string;
|
2021-11-16 21:14:46 -05:00
|
|
|
|
2021-11-20 20:18:58 -05:00
|
|
|
@Column({ nullable: false })
|
2021-11-23 16:04:12 -05:00
|
|
|
passwordHash: string;
|
|
|
|
|
|
|
|
@OneToMany(() => RefreshToken, (token) => token.user)
|
|
|
|
refreshTokens: RefreshToken[];
|
2021-11-30 17:40:07 -05:00
|
|
|
|
2021-11-30 19:44:58 -05:00
|
|
|
@OneToMany(() => UserRole, (userRole) => userRole.user, { cascade: true })
|
2021-11-30 17:40:07 -05:00
|
|
|
userRoles: UserRole[];
|
2022-03-30 17:18:16 -04:00
|
|
|
|
|
|
|
@OneToMany(() => ChatRoom, (chatRoom) => chatRoom.user)
|
|
|
|
chatRooms: ChatRoom[];
|
2021-11-20 20:18:58 -05:00
|
|
|
}
|