import { BaseRepository } from '#application/base/baseRepository' import { UUID } from '#application/types' import { Sprite } from '#entities/sprite' class SpriteRepository extends BaseRepository { async getById(id: UUID, populate?: any) { try { const repository = this.getEntityManager().getRepository(Sprite) const result = await repository.findOne({ id }, { populate }) if (result) result.setEntityManager(this.getEntityManager()) return result } catch (error: any) { return null } } async getAll(populate?: any): Promise { try { const repository = this.getEntityManager().getRepository(Sprite) return await repository.findAll({ populate }) } catch (error: any) { return [] } } async getFirst(populate?: any): Promise { try { const repository = this.getEntityManager().getRepository(Sprite) const result = await repository.findOne({ id: { $exists: true } }, { populate }) if (result) result.setEntityManager(this.getEntityManager()) return result } catch (error: any) { return null } } } export default SpriteRepository