Skip to content

Commit

Permalink
feat(repository): feat(repository): implement undo soft delete feature
Browse files Browse the repository at this point in the history
add undo soft delete functionalities =undoById and undoByAll
GH-182
  • Loading branch information
sf-sahil-jassal committed Dec 7, 2023
1 parent bc202f4 commit 8c80bc1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/repositories/soft-crud.repository.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,35 @@ export abstract class SoftCrudRepository<
);
}

/**
* Method to perform undo the soft delete by Id.
* @param id
* @param options
*/
async undoSoftDeleteById(id: ID, options?: Options): Promise<void> {
return super.updateById(
id,
{
deleted: false,
deletedOn: undefined,
},
options,
);
}

/**
* Method to perform undo all the soft deletes
* @param id
* @param options
*/
async undoSoftDeleteAll(where?: Where<E>, options?: Options): Promise<Count> {
const dataToUpdate: DataObject<E> = {
deleted: false,
deletedOn: undefined,
};
return super.updateAll(dataToUpdate, where, options);
}

/**
* Method to perform hard delete of entries. Take caution.
* @param entity
Expand Down

0 comments on commit 8c80bc1

Please sign in to comment.