Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
fix(repository): make deleteById independent
Browse files Browse the repository at this point in the history
Removed Internal Call of `deleteAll` inside `deleteById` function for predictable outputs

GH-12
  • Loading branch information
shubhamp-sf committed Jan 19, 2023
1 parent 926bc8e commit b8aa033
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sequelize/sequelize.repository.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,12 @@ export class SequelizeCrudRepository<

const where = {} as Where<T>;
(where as AnyObject)[idProp] = id;
const result = await this.deleteAll(where, options);
const count = await this.sequelizeModel.destroy({
where: this.buildSequelizeWhere(where),
...options,
});

if (result.count === 0) {
if (count === 0) {
throw new EntityNotFoundError(this.entityClass, id);
}
}
Expand Down Expand Up @@ -1023,7 +1026,7 @@ export class SequelizeCrudRepository<
relation.filter.scope?.include,
);

normalizedParentEntities.map(entity => {
normalizedParentEntities.forEach(entity => {
// let columnValue = entity[relation.definition.keyFrom as keyof T];
const foreignKeys = entity[relation.definition.keyFrom as keyof T];
const filteredChildModels = childModelData.filter(childModel => {
Expand Down

0 comments on commit b8aa033

Please sign in to comment.