Missing Transaction For Multi Write (ARCH3065)
Ce contenu n’est pas encore disponible dans votre langue.
Key typescript.orm.missing-transaction-for-multi-write · Severity warning · Category orm
When two or more dependent persistence operations in the same method are not wrapped in an explicit transaction/atomic block, a partial commit can occur. Wrap dependent writes.
Incorrect
Section titled “Incorrect”await accountRepo.save(debit); // succeedsawait accountRepo.save(credit); // if this fails, debit is left committedCorrect
Section titled “Correct”await dataSource.transaction(async (tx) => { await tx.save(debit); await tx.save(credit);});Group dependent write operations inside a single transaction/atomic block.