Newer
Older
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
import { FactionEntity } from '../faction/faction.entity';
@Entity('MapDrawing')
export class MapDrawingEntity {
@PrimaryGeneratedColumn('uuid') mapDrawingId: string;
@Column({ type: 'bool', nullable: true }) drawingIsActive: boolean;
@Column({ type: 'time', nullable: true }) drawingValidTill: string;
@ManyToOne(type => FactionEntity, faction => faction.mapDrawings, {
onDelete: 'CASCADE',
})
@ManyToOne(type => GameEntity, gameEntity => gameEntity.id, {
onDelete: 'CASCADE',
})
async ownershipCheck(factionEntity, role) {
if (role === 'admin') {
return factionEntity == this.faction;
} else {
return this.faction && factionEntity.factionId === this.faction.factionId
? true
: false;
}
}