fix: all sql queries should be under one transaction

This commit is contained in:
Ahmed Bouhuolia
2024-06-07 01:30:08 +02:00
parent 494d2c1fe0
commit 3dadbeac4d

View File

@@ -46,7 +46,7 @@ export class PlaidSyncDb {
trx?: Knex.Transaction
) {
const { Account } = this.tenancy.models(tenantId);
const plaidAccount = Account.query().findOne(
const plaidAccount = await Account.query().findOne(
'plaidAccountId',
createBankAccountDTO.plaidAccountId
);
@@ -101,11 +101,11 @@ export class PlaidSyncDb {
): Promise<void> {
const { Account } = this.tenancy.models(tenantId);
const cashflowAccount = await Account.query()
const cashflowAccount = await Account.query(trx)
.findOne({ plaidAccountId })
.throwIfNotFound();
const openingEquityBalance = await Account.query().findOne(
const openingEquityBalance = await Account.query(trx).findOne(
'slug',
'opening-balance-equity'
);