import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core' import { BaseEntity } from '#application/base/baseEntity' import { Character } from './character' import { Item } from './item' import { CharacterEquipment } from './characterEquipment' @Entity() export class CharacterItem extends BaseEntity { @PrimaryKey() id!: number @ManyToOne(() => Character) character!: Character @ManyToOne(() => Item) item!: Item @Property() quantity!: number @OneToMany(() => CharacterEquipment, (equipment) => equipment.characterItem) characterEquipment = new Collection(this) setId(id: number) { this.id = id return this } getId() { return this.id } setCharacter(character: Character) { this.character = character return this } getCharacter() { return this.character } setItem(item: Item) { this.item = item return this } getItem() { return this.item } setQuantity(quantity: number) { this.quantity = quantity return this } getQuantity() { return this.quantity } setCharacterEquipment(characterEquipment: Collection) { this.characterEquipment = characterEquipment return this } getCharacterEquipment() { return this.characterEquipment } }