Commit 3e5bcdcb authored by nanahira's avatar nanahira

fix

parent 6bae51cd
......@@ -159,20 +159,18 @@ export class CrudBase<
}
async remove(id: EntityId<T>) {
let result: UpdateResult;
try {
const result = await this.repo.update({ id, isDeleted: false }, {
result = await this.repo.update({ id, isDeleted: false }, {
isDeleted: true,
} as Partial<T>);
if (!result.affected) {
throw new BlankReturnMessageDto(
404,
`ID ${id} not found.`,
).toException();
}
return new BlankReturnMessageDto(200, 'success');
} catch (e) {
this.error(`Failed to delete entity ID ${id}: ${e.toString()}`);
throw new BlankReturnMessageDto(500, 'internal error').toException();
}
if (!result.affected) {
throw new BlankReturnMessageDto(404, `ID ${id} not found.`).toException();
}
return new BlankReturnMessageDto(200, 'success');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment