|
1 | 1 | import { Injectable } from '@nestjs/common';
|
2 |
| -import { |
3 |
| - DuplicateException, |
4 |
| - ID, |
5 |
| - NotFoundException, |
6 |
| - ServerException, |
7 |
| - Session, |
8 |
| -} from '~/common'; |
9 |
| -import { e, EdgeDB, isExclusivityViolation } from '~/core/edgedb'; |
| 2 | +import { ID, NotFoundException, Session } from '~/common'; |
| 3 | +import { e, EdgeDB } from '~/core/edgedb'; |
10 | 4 | import { CreatePerson, User, UserListInput } from './dto';
|
11 | 5 | import { UserRepository } from './user.repository';
|
12 | 6 |
|
@@ -83,29 +77,14 @@ export class UserEdgedbRepository extends UserRepository {
|
83 | 77 |
|
84 | 78 | async create(input: CreatePerson) {
|
85 | 79 | const query = e.insert(e.User, { ...input });
|
86 |
| - try { |
87 |
| - const result = await this.edgedb.run(query); |
88 |
| - return result.id; |
89 |
| - } catch (e) { |
90 |
| - if (isExclusivityViolation(e, 'email')) { |
91 |
| - throw new DuplicateException( |
92 |
| - 'person.email', |
93 |
| - 'Email address is already in use', |
94 |
| - e, |
95 |
| - ); |
96 |
| - } |
97 |
| - throw new ServerException('Failed to create user', e); |
98 |
| - } |
| 80 | + const result = await this.edgedb.run(query); |
| 81 | + return result.id; |
99 | 82 | }
|
100 | 83 |
|
101 | 84 | async delete(id: ID, _session: Session, _object: User): Promise<void> {
|
102 | 85 | const query = e.delete(e.User, () => ({
|
103 | 86 | filter_single: { id },
|
104 | 87 | }));
|
105 |
| - try { |
106 |
| - await this.edgedb.run(query); |
107 |
| - } catch (exception) { |
108 |
| - throw new ServerException('Failed to delete', exception); |
109 |
| - } |
| 88 | + await this.edgedb.run(query); |
110 | 89 | }
|
111 | 90 | }
|
0 commit comments