OOP is my passion ( ͡° ͜ʖ ͡°)
This commit is contained in:
@ -5,7 +5,7 @@ import { Item } from '#entities/item'
|
||||
class ItemRepository extends BaseRepository {
|
||||
async getById(id: UUID): Promise<any> {
|
||||
try {
|
||||
const repository = this.em.getRepository(Item)
|
||||
const repository = this.getEntityManager().getRepository(Item)
|
||||
return await repository.findOne({ id })
|
||||
} catch (error: any) {
|
||||
this.logger.error(`Failed to get item by ID: ${error instanceof Error ? error.message : String(error)}`)
|
||||
@ -15,7 +15,7 @@ class ItemRepository extends BaseRepository {
|
||||
|
||||
async getByIds(ids: UUID[]): Promise<any> {
|
||||
try {
|
||||
const repository = this.em.getRepository(Item)
|
||||
const repository = this.getEntityManager().getRepository(Item)
|
||||
return await repository.find({
|
||||
id: ids
|
||||
})
|
||||
@ -27,7 +27,7 @@ class ItemRepository extends BaseRepository {
|
||||
|
||||
async getAll(): Promise<any> {
|
||||
try {
|
||||
const repository = this.em.getRepository(Item)
|
||||
const repository = this.getEntityManager().getRepository(Item)
|
||||
return await repository.findAll()
|
||||
} catch (error: any) {
|
||||
this.logger.error(`Failed to get all items: ${error instanceof Error ? error.message : String(error)}`)
|
||||
@ -36,4 +36,4 @@ class ItemRepository extends BaseRepository {
|
||||
}
|
||||
}
|
||||
|
||||
export default new ItemRepository()
|
||||
export default ItemRepository
|
||||
|
Reference in New Issue
Block a user