diff --git a/src/lib/server/db/repos/lowdb/deviceRepo.ts b/src/lib/server/db/repos/lowdb/deviceRepo.ts index 68acf5e..17584da 100644 --- a/src/lib/server/db/repos/lowdb/deviceRepo.ts +++ b/src/lib/server/db/repos/lowdb/deviceRepo.ts @@ -21,7 +21,7 @@ export class LowDeviceRepo implements IDeviceRepo { } async create(device: New): Promise { - if (this.db.data.devices.find((d) => d.name === device.name)) { + if (this.db.data.devices.some((d) => d.name === device.name)) { return DeviceErrors.DUPLICATE_NAME; } @@ -33,7 +33,7 @@ export class LowDeviceRepo implements IDeviceRepo { } async update(device: Updated): Promise { - if (this.db.data.devices.find((d) => d.name === device.name && d.id !== device.id)) { + if (this.db.data.devices.some((d) => d.name === device.name && d.id !== device.id)) { return DeviceErrors.DUPLICATE_NAME; } diff --git a/src/lib/server/db/repos/lowdb/groupRepo.ts b/src/lib/server/db/repos/lowdb/groupRepo.ts index 9288c0d..78b87f0 100644 --- a/src/lib/server/db/repos/lowdb/groupRepo.ts +++ b/src/lib/server/db/repos/lowdb/groupRepo.ts @@ -21,7 +21,7 @@ export class LowGroupRepo implements IGroupRepo { } async create(group: New): Promise { - if (this.db.data.groups.find((g) => g.name === group.name)) { + if (this.db.data.groups.some((g) => g.name === group.name)) { return GroupErrors.DUPLICATE_NAME; } diff --git a/src/lib/server/db/repos/lowdb/userRepo.ts b/src/lib/server/db/repos/lowdb/userRepo.ts index d8af2cf..46dad45 100644 --- a/src/lib/server/db/repos/lowdb/userRepo.ts +++ b/src/lib/server/db/repos/lowdb/userRepo.ts @@ -51,7 +51,7 @@ export class LowUserRepo implements IUserRepo { } async update(user: Updated) { - if (this.db.data.users.find((u) => u.name == user.name && u.id != user.id)) { + if (this.db.data.users.some((u) => u.name == user.name && u.id != user.id)) { return UserErrors.DUPLICATE_NAME; }