From 82e1512ccba45e53df66529270e58f84a2910247 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Thu, 4 Apr 2024 22:20:51 -0400 Subject: [PATCH] Start the Image repository. --- app/src/domain/repository/image-repository.ts | 12 ++++++++++++ app/src/domain/repository/user-repository.ts | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 app/src/domain/repository/image-repository.ts diff --git a/app/src/domain/repository/image-repository.ts b/app/src/domain/repository/image-repository.ts new file mode 100644 index 0000000..6910d74 --- /dev/null +++ b/app/src/domain/repository/image-repository.ts @@ -0,0 +1,12 @@ +import { type Repository } from '@slovo/domain/repository'; +import { Entity, type EntityId } from '@slovo/domain/entity'; +import { Image } from '@slovo/models/image'; +import connectionPool from '@slovo/infrastructure/connection-pool'; + +export class ImageRepository implements Repository { + public async get(id: EntityId): Promise> { + const conn = await connectionPool.getConnection(); + + await conn.release(); + } +} diff --git a/app/src/domain/repository/user-repository.ts b/app/src/domain/repository/user-repository.ts index 9bb9f81..d313070 100644 --- a/app/src/domain/repository/user-repository.ts +++ b/app/src/domain/repository/user-repository.ts @@ -52,7 +52,12 @@ export class UserRepository implements Repository { user.getId() ]); + if (!results.length) { + throw Error("Unable to update the User"); + } + await conn.release(); + return user; } public async delete(user: Entity): Promise {