Skip to content

Commit

Permalink
fix: fail if updating or removing by non-existing id
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-bechara committed May 3, 2021
1 parent da2eefd commit ce2acc3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/orm/orm.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export abstract class OrmService<Entity> {
* @param options
*/
public async updateById(id: string, data: EntityData<Entity>, options: OrmUpdateOptions<Entity> = { }): Promise<Entity> {
const entity = await this.readById(id);
const entity = await this.readByIdOrFail(id);
const updatedEntity = await this.update({ entity, data }, options);
return updatedEntity[0];
}
Expand Down Expand Up @@ -462,7 +462,7 @@ export abstract class OrmService<Entity> {
* @param id
*/
public async removeById(id: string): Promise<Entity> {
const entity = await this.readById(id);
const entity = await this.readByIdOrFail(id);
await this.remove(entity);
return entity;
}
Expand Down

0 comments on commit ce2acc3

Please sign in to comment.