2021-01-01 18:46:16 +02:00
|
|
|
const Transaction = require('../../../execution/transaction');
|
2020-12-30 16:13:35 +00:00
|
|
|
|
|
|
|
class Transaction_PG extends Transaction {
|
|
|
|
begin(conn) {
|
2023-03-29 04:59:05 -07:00
|
|
|
const trxMode = [
|
|
|
|
this.isolationLevel ? `ISOLATION LEVEL ${this.isolationLevel}` : '',
|
|
|
|
this.readOnly ? 'READ ONLY' : '',
|
|
|
|
]
|
|
|
|
.join(' ')
|
|
|
|
.trim();
|
|
|
|
|
|
|
|
if (trxMode.length === 0) {
|
|
|
|
return this.query(conn, 'BEGIN;');
|
2020-12-30 16:13:35 +00:00
|
|
|
}
|
2023-03-29 04:59:05 -07:00
|
|
|
return this.query(conn, `BEGIN TRANSACTION ${trxMode};`);
|
2020-12-30 16:13:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Transaction_PG;
|