import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, OneToMany, Timestamp, } from 'typeorm'; import { PersonEntity } from 'src/user/user.entity'; // table that stores all created games @Entity('Game') export class GameEntity { @PrimaryGeneratedColumn('uuid') id: string; @Column('text') name: string; @Column('text') desc: string; @Column('json') center: JSON; @Column('json') map: JSON; @Column('timestamp') startdate: Timestamp; @Column('timestamp') enddate: Timestamp; @Column("text", {array: true}) passwords: string[]; @OneToMany(type => FactionEntity, faction => faction.game) factions: FactionEntity[]; @OneToMany(type => Game_PersonEntity, game_persons => game_persons.game) game_persons: Game_PersonEntity[]; gameObject() { const { id, name } = this; return { id, name }; } } // table that stores all factions created for games @Entity('Faction') export class FactionEntity { @PrimaryGeneratedColumn('uuid') id: string; @Column('text') name: string; @ManyToOne(type => GameEntity, game => game.factions) game: GameEntity; @OneToMany(type => Game_PersonEntity, game_persons => game_persons.faction) game_persons: Game_PersonEntity[]; } // table that stores players associated with particular game @Entity('Game_Person') export class Game_PersonEntity { @PrimaryGeneratedColumn('uuid') gameId: string; @ManyToOne(type => FactionEntity, faction => faction.game_persons) faction: FactionEntity; @ManyToOne(type => GameEntity, game => game.game_persons) game: GameEntity; @ManyToOne(type => PersonEntity, person => person.game_persons) person: PersonEntity; /* @ManyToOne(type => PersonRoleEntity, person_role => person_role.game_persons) person_role: PersonRoleEntity; @ManyToMany(type => CoordinateEntity, game_person_coordinates => game_person_coordinates.game_persons) game_person_coordinates: CoordinateEntity[]; */ }