mirror of
https://github.com/strapi/strapi.git
synced 2025-07-20 23:47:46 +00:00
19 lines
340 B
JavaScript
19 lines
340 B
JavaScript
'use strict';
|
|
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
const storage = new AsyncLocalStorage();
|
|
|
|
const transactionCtx = {
|
|
async run(store, cb) {
|
|
return storage.run(store, cb);
|
|
},
|
|
|
|
get() {
|
|
const trx = storage.getStore();
|
|
return trx?.isCompleted() ? undefined : trx;
|
|
},
|
|
};
|
|
|
|
module.exports = transactionCtx;
|