typeorm-transactional icon indicating copy to clipboard operation
typeorm-transactional copied to clipboard

[Feature Request] Implement @Transactional() decorator on class level

Open Aliheym opened this issue 2 years ago • 1 comments

Description

Allow using @Transactional() decorator with the entire class (apply to all methods). This decorator needs to have the same interface as the existing one. We also need a possibility to ignore some class methods (something like another decorator or additional option).

@Transactional({ propagation: Propagation.REQUIRES_NEW })
class PostsService {
  constructor() {
    // ...
  }
  
  // If we need to ignore we can use a new decorator @NonTransactional() 
  // or using new option @Transactional({ ignore: true }) (?) think about it
  async getPostById() {
     // ...
   }
  
  // If we use explicit`@Transactional()  then we need to override options that were defined in class-level `@Transactional`
  @Transactional({  propagation: Propagation.NESTED })
  async updatePost() {
     // ...
   }
}

Of course, we need tests and documentation for these new features.

Aliheym avatar Aug 22 '22 06:08 Aliheym

Hi @Aliheym, when this ready to be used ?

vvtri avatar Jun 09 '23 06:06 vvtri