github
10228 of 13274 branches covered (0.0%)
Branch coverage included in aggregate %.
2332 of 2504 new or added lines in 42 files covered. (93.13%)
22 existing lines in 7 files now uncovered.22613 of 25373 relevant lines covered (89.12%)
3125.66 hits per line
1 |
'use strict';
|
|
2 |
|
|
3 |
module.exports = function (module) { |
5✔ |
|
module.transaction = async function (perform, txClient) {
|
5✔ |
5 |
let res; |
|
|
if (txClient) {
|
|
NEW
|
await txClient.query(`SAVEPOINT nodebb_subtx`); |
× |
NEW
|
try {
|
× |
NEW
|
res = await perform(txClient); |
× |
10 |
} catch (err) {
|
|
NEW
|
await txClient.query(`ROLLBACK TO SAVEPOINT nodebb_subtx`); |
× |
NEW
|
throw err;
|
× |
13 |
} |
|
NEW
|
await txClient.query(`RELEASE SAVEPOINT nodebb_subtx`); |
× |
NEW
|
return res;
|
× |
16 |
} |
|
17 |
// see https://node-postgres.com/features/transactions#a-pooled-client-with-async-await
|
|
|
const client = await module.pool.connect(); |
23,600✔ |
19 |
|
|
|
try {
|
23,600✔ |
|
await client.query('BEGIN');
|
23,600✔ |
|
res = await perform(client); |
23,600✔ |
|
await client.query('COMMIT');
|
23,600✔ |
24 |
} catch (err) {
|
|
NEW
|
await client.query('ROLLBACK');
|
× |
NEW
|
throw err;
|
× |
27 |
} finally {
|
|
|
client.release(); |
23,600✔ |
29 |
} |
|
|
return res;
|
23,600✔ |
31 |
}; |
|
32 |
}; |