LocChat/server/entities/user.entity.ts

32 lines
802 B
TypeScript
Raw Normal View History

2021-11-23 16:04:12 -05:00
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
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[];
@OneToMany(() => ChatRoom, (chatRoom) => chatRoom.user)
chatRooms: ChatRoom[];
2021-11-20 20:18:58 -05:00
}