0-vortex / nestjs-documents-api

nestjs example for document editing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fix: wrap `publishOneByIdAndDraftId` sql in same transaction

0-vortex opened this issue · 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.