0-vortex/nestjs-documents-api

fix: wrap `publishOneByIdAndDraftId` sql in same transaction

0-vortex opened this issue · 0 comments

An additional table locking mechanism could have been used depending on which data storage layer is used. Currently the API routes for creation and publication use postgresql transactions, but in this scenario a transaction encapsulating all the 2-3 commands should have been used and opted publishOneByIdAndDraftId service function. I forgot to wrap the documentVersionRepository and documentRepository save calls in the same transaction. I used TypeOrm for some advantages, however writing pure SQL here could have solved the trick much faster and not become an oversight.