forked from noxious/server
Almost finalised refactoring
This commit is contained in:
@ -1,22 +1,23 @@
|
||||
import { BaseRepository } from '#application/base/baseRepository'
|
||||
import { UUID } from '#application/types'
|
||||
import { MapObject } from '#entities/mapObject'
|
||||
|
||||
class MapObjectRepository extends BaseRepository {
|
||||
async getById(id: UUID): Promise<any> {
|
||||
async getById(id: UUID): Promise<MapObject | null> {
|
||||
try {
|
||||
const repository = this.em.getRepository(Object)
|
||||
const repository = this.em.getRepository(MapObject)
|
||||
return await repository.findOne({ id })
|
||||
} catch (error: any) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async getAll(): Promise<any> {
|
||||
async getAll(): Promise<MapObject[]> {
|
||||
try {
|
||||
const repository = this.em.getRepository(Object)
|
||||
const repository = this.em.getRepository(MapObject)
|
||||
return await repository.findAll()
|
||||
} catch (error: any) {
|
||||
return null
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user