1
0
forked from noxious/server

Added ORM entities

This commit is contained in:
2024-12-24 22:08:08 +01:00
parent 40c24cee10
commit 8980691409
15 changed files with 403 additions and 1 deletions

37
src/entities/item.ts Normal file
View File

@ -0,0 +1,37 @@
import { Collection, Entity, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { Sprite } from './sprite';
import { CharacterItem } from './characterItem';
import { ItemType, ItemRarity } from '../utilities/enums';
@Entity()
export class Item {
@PrimaryKey()
id!: string;
@Property()
name!: string;
@Property({ nullable: true })
description?: string;
@Property()
itemType!: ItemType;
@Property()
stackable = false;
@Property()
rarity: ItemRarity = ItemRarity.COMMON;
@ManyToOne(() => Sprite, { nullable: true })
sprite?: Sprite;
@Property()
createdAt = new Date();
@Property()
updatedAt = new Date();
@OneToMany(() => CharacterItem, characterItem => characterItem.item)
characters = new Collection<CharacterItem>(this);
}