Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('works', function(done) {
var client1 = new pg.Client()
client1.connect()
var client2 = new pg.Client()
client2.connect()
var qr = new QueryStream("INSERT INTO p DEFAULT VALUES RETURNING id")
client1.query(qr)
var id = null
qr.on('data', function(row) {
id = row.id
})
qr.on('end', function () {
client2.query("INSERT INTO c(id) VALUES ($1)", [id], function (err, rows) {
client1.end()
client2.end()
done(err)
})
})
})
before(function(done) {
var client = new pg.Client()
client.connect()
client.on('drain', client.end.bind(client))
client.on('end', done)
client.query('create table IF NOT EXISTS p(id serial primary key)')
client.query('create table IF NOT EXISTS c(id int primary key references p)')
})
it('works', function(done) {
it('works', function(done) {
var client1 = new pg.Client()
client1.connect()
var client2 = new pg.Client()
client2.connect()
var qr = new QueryStream("INSERT INTO p DEFAULT VALUES RETURNING id")
client1.query(qr)
var id = null
qr.on('data', function(row) {
id = row.id
})
qr.on('end', function () {
client2.query("INSERT INTO c(id) VALUES ($1)", [id], function (err, rows) {
client1.end()
client2.end()
done(err)
})
describe(name, function() {
var client = new pg.Client()
before(function(done) {
client.connect(done)
})
cb(client)
after(function(done) {
client.end()
client.on('end', done)
})
})
}
return function query(text, values, cb) {
var client = new pg.Client(connString);
//client.connect();
//if (typeof text === 'object') return client.query(text);
if (typeof values === 'function') {
cb = values;
values = [];
}
client.connect(function(err) {
if (err) return cb(err);
client.query(text, values, function(err, result) {
client.end();
if (err) return cb(err);
return cb(err, result.rows, result);
});
});
};
};