Skip to content

Commit 489dca6

Browse files
committed
update repo
1 parent 568be2e commit 489dca6

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/auth/auth.repository.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,17 @@ import { User } from "users/users.model";
44

55
export class AuthRepository {
66
public async createUser(payload: RegisterPayload) {
7-
const createUserQuery =
8-
"INSERT INTO users (username, email, password) VALUES ($1, $2, $3) RETURNING *";
9-
10-
const result = await pool.query<User>(createUserQuery, [
11-
payload.username,
12-
payload.email,
13-
payload.password,
14-
]);
15-
if (result.rows.length === 0) return null;
7+
const result = await pool.query<User>(
8+
"INSERT INTO users (username, email, password) VALUES ($1, $2, $3) RETURNING *",
9+
[payload.username, payload.email, payload.password]
10+
);
1611
return result.rows[0];
1712
}
1813

1914
public async findUserById(id: number) {
2015
const result = await pool.query<User>("SELECT * FROM users WHERE id = $1", [
2116
id,
2217
]);
23-
if (result.rows.length === 0) return null;
2418
return result.rows[0];
2519
}
2620

@@ -29,7 +23,6 @@ export class AuthRepository {
2923
"SELECT * FROM users WHERE email = $1",
3024
[email]
3125
);
32-
if (result.rows.length === 0) return null;
3326
return result.rows[0];
3427
}
3528
}

0 commit comments

Comments
 (0)