'TypeORM using SoftTDelete @BeforeRemove

Why is the @BeforeRemove trigger only executed with the manager.remove() method and it permanently deletes the record from the database table? Why is this @BeforeRemove trigger not executed by manager.softRemove() for example? It makes no sense to fill a deleted_at column and then delete the record using manage.remove()!

@BeforeRemove()
  delete() {
    this.deleted_by = 'MyName'
}

// Run only with manage.remove

async remove(request: Request, _response: Response, next: NextFunction) {
  let userToRemove: any = await this.userRepository.findOne(request.params.id);

  return await this.userRepository.softRemove(userToRemove);
}

// softRemove does not run @BeforeRemove /:



Solution 1:[1]

https://github.com/typeorm/typeorm/releases/tag/0.2.42

Resolved in the release 0.2.42

https://github.com/typeorm/typeorm/pull/8403

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user18246725