Skip to content

Commit e491450

Browse files
authored
Fix TypeScript error in SQL docs for UsersService
The function type return `findOne` of UsersService seems incorrect. The line `this.usersRepository.findOneBy({ id })` returns a `User` or `null` if no user with the matching id is found. However, the function return is `Promise<User>`. Also, the parameter `id` of the `remove` function for UsersService is a `string` which is inconsistent with all the other functions of UsersService where the parameter `id` is a `number`
1 parent b31ab0d commit e491450

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/techniques/sql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ export class UsersService {
180180
return this.usersRepository.find();
181181
}
182182

183-
findOne(id: number): Promise<User> {
183+
findOne(id: number): Promise<User | null> {
184184
return this.usersRepository.findOneBy({ id });
185185
}
186186

187-
async remove(id: string): Promise<void> {
187+
async remove(id: number): Promise<void> {
188188
await this.usersRepository.delete(id);
189189
}
190190
}

0 commit comments

Comments
 (0)