forked from noxious/server
Temp. fix for populating
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import { BaseRepository } from '#application/base/baseRepository'
|
||||
import { UUID } from '#application/types'
|
||||
import { Character } from '#entities/character'
|
||||
import { RequiredEntityData } from '@mikro-orm/core'
|
||||
|
||||
class CharacterRepository extends BaseRepository {
|
||||
async getByUserId(userId: UUID, populate?: any): Promise<Character[]> {
|
||||
@ -24,20 +23,20 @@ class CharacterRepository extends BaseRepository {
|
||||
}
|
||||
}
|
||||
|
||||
async getById(id: UUID, populate?: string[]): Promise<Character | null> {
|
||||
async getById(id: UUID, populate?: any): Promise<Character | null> {
|
||||
try {
|
||||
const repository = this.em.getRepository(Character)
|
||||
return await repository.findOne({ id })
|
||||
return await repository.findOne({ id }, { populate })
|
||||
} catch (error: any) {
|
||||
this.logger.error(`Failed to get character by ID: ${error instanceof Error ? error.message : String(error)}`)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async getByName(name: string): Promise<Character | null> {
|
||||
async getByName(name: string, populate?: any): Promise<Character | null> {
|
||||
try {
|
||||
const repository = this.em.getRepository(Character)
|
||||
return await repository.findOne({ name })
|
||||
return await repository.findOne({ name }, { populate })
|
||||
} catch (error: any) {
|
||||
this.logger.error(`Failed to get character by name: ${error instanceof Error ? error.message : String(error)}`)
|
||||
return null
|
||||
|
Reference in New Issue
Block a user