Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as lib from "pg-promise";
var pgp = lib({
capSQL: true,
pgFormatting: true,
pgNative: true
});
interface Test {
hello:string;
}
var db = pgp('connection');
var txMode = new lib.txMode.TransactionMode();
function myTransaction(t) {
}
myTransaction['txMode'] = txMode;
db.tx(function (t) {
var w = t.one('');
var q = t.hello;
});
return final + pgp.queryResult[mask]
}, 0)
if (script.transaction) {
if (typeof script.transaction !== 'object') {
script.transaction = {}
}
if (!script.transaction.tag) {
script.transaction.tag = script.name
}
if (script.transaction.isolation) {
assert(pgp.txMode.isolationLevel.hasOwnProperty(script.transaction.isolation), `Script at ${path} specified invalid transaction isolation level "${script.transaction.isolation}"`)
}
script.transaction.mode = new pgp.txMode.TransactionMode(script.transaction.isolation, script.transaction.readOnly, script.transaction.deferrable)
script.transaction.options = {
tag: script.transaction.tag,
mode: script.transaction.mode
}
if (typeof script.execute === 'function') {
const userFn = script.execute
script.execute = (arg) => {
return db.tx(script.transaction.options, (d) => userFn(d, arg))
}
} else {
assert(typeof script.query === 'string', `Script at ${path} must specify a "query" property`)
script.execute = (arg) => {
return db.tx(script.transaction.options, (d) => d.query(script.query, arg, script.returns))
}