Closed thobui14ig closed 1 year ago
Hello @thobui14ig , can you give more information about what you want to do if possible?
Do you want to run your code in one transaction?
await this.resourcesRepository.save(data);
await this.userService.saveUser();
yes, i want one transaction, that is two difference service, if this.userService.saveUser() error i want rollback this.resourcesRepository.save(data), help me
Hello @thobui14ig , can you give more information about what you want to do if possible?
Do you want to run your code in one transaction?
await this.resourcesRepository.save(data); await this.userService.saveUser();
help me
Hi, @thobui14ig.
Transactional
decorator in the method that contains a code that you want to "wrap" in the one transactions. For example it can be a controller method:@Patch('/users/:id`)
@Transactional()
async updateUser(data) {
await this.resourcesRepository.save(data);
await this.userService.saveUser();
}
or it can be any other method:
class UsersService {
@Transactional()
async updateUser(data) {
await this.resourcesRepository.save(data);
await this.userService.saveUser();
}
You can ask questions if you have troubles with something.
Feel free to reopen if you have issues.
how to use 2 service transaction, hellpe me, i am from VietNam await this.resourcesRepository.save(data); await this.userService.saveUser();