import { randomUUID } from 'node:crypto' import { ManyToOne, PrimaryKey, Property } from '@mikro-orm/core' import type { UUID } from '#application/types' import type { Character } from '#entities/character' import type { Item } from '#entities/item' import { BaseEntity } from '#application/base/baseEntity' export class BaseCharacterItem extends BaseEntity { @PrimaryKey() id = randomUUID() @ManyToOne({ deleteRule: 'cascade' }) character!: Character @ManyToOne({ deleteRule: 'cascade' }) item!: Item @Property() quantity!: number setId(id: UUID) { 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 } }