Files
klz-cables.com/.pnpm-store/v10/files/3b/e395c31409c178b2edc343fc05b0cdf2a84a50a4728daf82c061eacc6ef45a14a05cecbc2db6630996aeeef2c797d83914ed347aeb4b9dad0b92ecdfc39c60
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

28 lines
1.0 KiB
Plaintext

/**
* Starts a new transaction using the db adapter with a random id and then assigns it to the req.transaction
* @returns true if beginning a transaction and false when req already has a transaction to use
*/ export async function initTransaction(req) {
const { payload, transactionID } = req;
if (transactionID instanceof Promise) {
// wait for whoever else is already creating the transaction
await transactionID;
return false;
}
if (transactionID) {
// we already have a transaction, we're not in charge of committing it
return false;
}
if (typeof payload.db.beginTransaction === 'function') {
// create a new transaction
req.transactionID = payload.db.beginTransaction().then((transactionID)=>{
if (transactionID) {
req.transactionID = transactionID;
}
return transactionID;
});
return !!await req.transactionID;
}
return false;
}
//# sourceMappingURL=initTransaction.js.map