LocChat/server/entities/user.entity.ts

25 lines
595 B
TypeScript
Raw Normal View History

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