Skip to content

Commit 908e022

Browse files
authored
TypeORM: ID column to string to support UUID (#442)
* Check PK data type to support uuid * Reflect that id is now an uuid and not a number
1 parent 8749932 commit 908e022

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

by-language/javascript-typeorm/src/controller/UserController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class UserController {
1111
}
1212

1313
async one(request: Request, response: Response, next: NextFunction) {
14-
const id = parseInt(request.params.id)
14+
const id = request.params.id
1515

1616

1717
const user = await this.userRepository.findOne({
@@ -37,7 +37,7 @@ export class UserController {
3737
}
3838

3939
async remove(request: Request, response: Response, next: NextFunction) {
40-
const id = parseInt(request.params.id)
40+
const id = request.params.id
4141

4242
let userToRemove = await this.userRepository.findOneBy({ id })
4343

@@ -50,4 +50,4 @@ export class UserController {
5050
return "user has been removed"
5151
}
5252

53-
}
53+
}

by-language/javascript-typeorm/src/entity/User.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"
44
export class User {
55

66
@PrimaryGeneratedColumn("uuid")
7-
id: number
7+
id: string
88

99
@Column()
1010
firstName: string

0 commit comments

Comments
 (0)