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

Commit 0ef9dfe

Browse files
authored
fix(repository): make deleteById independent (#13)
Removed Internal Call of `deleteAll` inside `deleteById` function for predictable outputs GH-12
1 parent 926bc8e commit 0ef9dfe

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/sequelize/sequelize.repository.base.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,12 @@ export class SequelizeCrudRepository<
322322

323323
const where = {} as Where<T>;
324324
(where as AnyObject)[idProp] = id;
325-
const result = await this.deleteAll(where, options);
325+
const count = await this.sequelizeModel.destroy({
326+
where: this.buildSequelizeWhere(where),
327+
...options,
328+
});
326329

327-
if (result.count === 0) {
330+
if (count === 0) {
328331
throw new EntityNotFoundError(this.entityClass, id);
329332
}
330333
}
@@ -1023,7 +1026,7 @@ export class SequelizeCrudRepository<
10231026
relation.filter.scope?.include,
10241027
);
10251028

1026-
normalizedParentEntities.map(entity => {
1029+
normalizedParentEntities.forEach(entity => {
10271030
// let columnValue = entity[relation.definition.keyFrom as keyof T];
10281031
const foreignKeys = entity[relation.definition.keyFrom as keyof T];
10291032
const filteredChildModels = childModelData.filter(childModel => {

0 commit comments

Comments
 (0)