Files
webapp-back/src/games/entities/player.entity.ts
T

33 lines
533 B
TypeScript

import { User } from 'src/users/entities/user.entity';
import {
Column,
Entity,
JoinTable,
ManyToMany,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
Unique,
} from 'typeorm';
import { Game } from './game.entity';
@Entity()
// @Unique(['user, game'])
export class Player {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(() => User, { eager: true })
user: User;
@ManyToOne(() => Game)
game: Game;
@Column({ default: 0 })
score: number;
get userId(): string {
return this.user.userId;
}
}