Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction management Question #22

Closed
hiteshjoshi1 opened this issue Jul 26, 2019 · 1 comment
Closed

Transaction management Question #22

hiteshjoshi1 opened this issue Jul 26, 2019 · 1 comment

Comments

@hiteshjoshi1
Copy link

I am trying to understand how to best implement Transaction management in NestJs but no luck so far.
How does transaction rollback happen when you are inserting in multiple tables and one of the insert succeeds and other one fails.
Example in nestjs-realworld-example-app/src/article/article.service.ts

In create(), if this succeeds

   const newArticle = await this.articleRepository.save(article);

but this fails

  await this.userRepository.save(author);
@lujakob
Copy link
Owner

lujakob commented Feb 14, 2020

This is not about NestJS but about how Typeorm handles transaction. For further info look at the following docs https://github.com/typeorm/typeorm/blob/master/docs/transactions.md

@lujakob lujakob closed this as completed Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants