From f49ed30587c2074b41af637c5523e5893c281adb Mon Sep 17 00:00:00 2001 From: hlcianfagna <110453267+hlcianfagna@users.noreply.github.com> Date: Fri, 3 May 2024 18:47:47 +0100 Subject: [PATCH 1/2] Check PK data type to support uuid --- by-language/javascript-typeorm/src/entity/User.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/by-language/javascript-typeorm/src/entity/User.ts b/by-language/javascript-typeorm/src/entity/User.ts index 37e9b414..4dbd1879 100644 --- a/by-language/javascript-typeorm/src/entity/User.ts +++ b/by-language/javascript-typeorm/src/entity/User.ts @@ -4,7 +4,7 @@ import { Entity, PrimaryGeneratedColumn, Column } from "typeorm" export class User { @PrimaryGeneratedColumn("uuid") - id: number + id: string @Column() firstName: string From b74c53b12cafba62aa29846169e02cfa2cdb4c77 Mon Sep 17 00:00:00 2001 From: hlcianfagna <110453267+hlcianfagna@users.noreply.github.com> Date: Fri, 3 May 2024 18:48:17 +0100 Subject: [PATCH 2/2] Reflect that id is now an uuid and not a number --- .../javascript-typeorm/src/controller/UserController.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/by-language/javascript-typeorm/src/controller/UserController.ts b/by-language/javascript-typeorm/src/controller/UserController.ts index 339a75b2..ab4d6199 100644 --- a/by-language/javascript-typeorm/src/controller/UserController.ts +++ b/by-language/javascript-typeorm/src/controller/UserController.ts @@ -11,7 +11,7 @@ export class UserController { } async one(request: Request, response: Response, next: NextFunction) { - const id = parseInt(request.params.id) + const id = request.params.id const user = await this.userRepository.findOne({ @@ -37,7 +37,7 @@ export class UserController { } async remove(request: Request, response: Response, next: NextFunction) { - const id = parseInt(request.params.id) + const id = request.params.id let userToRemove = await this.userRepository.findOneBy({ id }) @@ -50,4 +50,4 @@ export class UserController { return "user has been removed" } -} \ No newline at end of file +}