I have introduced certain decorators to the fields in my entity class that get triggered when an entity is saved using repository.save()
I am using entitySubscriber interface to check for events (Reference) and calling certain methods to perform an operation like this:
public beforeUpdate({ entity }: UpdateEvent<any>): void {
encryptData(entity);
}
But I noticed that this method is only called when we actually update certain fields in the entity. Is there a way to override this behaviour so that this method is called or in other words @BeforeUpdate hook is triggered every time we do a repository.save() ?
Nope unless you modify the TypeORM sourcecode.