Browse Source

use transaction instance

pull/1645/head
Bernd Storath 6 months ago
parent
commit
feb2f929e2
  1. 6
      src/server/database/repositories/user/service.ts

6
src/server/database/repositories/user/service.ts

@ -50,7 +50,11 @@ export class UserService {
const hash = await hashPassword(password); const hash = await hashPassword(password);
return this.#db.transaction(async (tx) => { return this.#db.transaction(async (tx) => {
const oldUser = await this.getByUsername(username); const oldUser = await tx.query.user
.findFirst({
where: eq(user.username, username),
})
.execute();
if (oldUser) { if (oldUser) {
throw new Error('User already exists'); throw new Error('User already exists');

Loading…
Cancel
Save