Skip to content

Commit a3fbd40

Browse files
committed
refactor(service/db/user) :modify create method to return created warning, remove async and save call; update count method to specify user id
1 parent a3c121c commit a3fbd40

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/service/db/user/warning.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { Warning } from "../../../entities/Warning";
55
export class WarningServiceDb extends DatabaseService {
66
private warningRepo = this.getRepo(Warning);
77

8-
async create(warning: Partial<Warning>): Promise<Warning> {
9-
const newWarning = this.warningRepo.create(warning);
10-
return this.warningRepo.save(newWarning);
8+
create(warning: Partial<Warning>): Warning {
9+
return this.warningRepo.create(warning);
1110
}
1211

1312
async save(warning: Warning) {
@@ -27,6 +26,6 @@ export class WarningServiceDb extends DatabaseService {
2726
}
2827

2928
async count(user: User) {
30-
return await this.warningRepo.count({ where: { user } });
29+
return await this.warningRepo.count({ where: { user: { id: user.id } } });
3130
}
3231
}

0 commit comments

Comments
 (0)