Aller au contenu

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.

await accountRepo.save(debit); // succeeds
await accountRepo.save(credit); // if this fails, debit is left committed
await dataSource.transaction(async (tx) => {
await tx.save(debit);
await tx.save(credit);
});

Group dependent write operations inside a single transaction/atomic block.