Enrico-git / WA2-EGLR

Laboratories and project of Web Application 2
0 stars 0 forks source link

[GraphQL] Use Transactions instead of chaining db operations in add comment function? #28

Closed thepassenger-hub closed 3 years ago

thepassenger-hub commented 3 years ago

Instead of using try/catch when we add the comment to the product we could use the transaction, so if there is an error in calculating the stars/adding the comment to the product document we dont have to delete the comment ourselves but an automatic rollback is performed.

https://mongoosejs.com/docs/transactions.html

thepassenger-hub commented 3 years ago

Fixed.