feat: deleteIfNoRelations

This commit is contained in:
Ahmed Bouhuolia
2025-06-28 22:35:29 +02:00
parent 0ca98c7ae4
commit fa5c3bd955
11 changed files with 229 additions and 143 deletions

View File

@@ -39,11 +39,8 @@ export class DeleteItemService {
// Retrieve the given item or throw not found service error.
const oldItem = await this.itemModel()
.query()
.findById(itemId)
.throwIfNotFound();
// .queryAndThrowIfHasRelations({
// type: ERRORS.ITEM_HAS_ASSOCIATED_TRANSACTIONS,
// });
.findOne('id', itemId)
.deleteIfNoRelations();
// Delete item in unit of work.
return this.uow.withTransaction(async (trx: Knex.Transaction) => {