originalClientConnect = pg.Client.prototype.connect; pg.Client.prototype.connect = function () { const handler = msg => {
async function startServer () { await client.connect() console.log('db connected') terminus(http.createServer(app), { logger: console.log, signal: 'SIGINT', healthChecks: { '/healthcheck': onHealthCheck }, onSignal }).listen(3000) }
async _createClient() { const client = new Client(this.options.connectionConfig); client.lock = new AwaitLock(); client.on('error', (error) => { this.emit('error', error, client); }); client.on('end', () => { this.emit('disconnect', client); }); await client.connect(); this.emit('connect', client); return client; }
clientData.connect().then((client) => { clientData.on('notification', function(msg) { console.log(msg); }); clientData.query('LISTEN watchers'); }).catch((err) => { console.log(err); });
Object.values(routes).forEach(({ method, path, handler }) => { api[method](path, async req => { const db = new pg.Client(config.get('db')); await db.connect(); try { return await handler( dbApi(db), serverConfig, importerApi(importerSendTxEndpoint), )(req); } finally { db.end(); } }); });
constructor() { this.client = new Client(config); this.client.connect(); }
db.connect((err, client) => { db.query(` CREATE TABLE IF NOT EXISTS snippets ( id SERIAL, PRIMARY KEY(id), body text ); ` , (err, result) => { if (err) throw err; console.log('Created table "snippets"'); db.end(); }); });
operation.attempt(function() { var client = new pg.Client() client.connect(function(e) { client.end() if(operation.retry(e)) { return; } if(!e) console.log("Hello Postgres!") }) })
db.connect((err, client) => { if (err) throw err; console.log('Connected to database', db.database); db.query(` SELECT * FROM snippets ORDER BY id `, (err, result) => { if (err) throw err; console.log(result.rows); db.end(); }); });
const initialise = async (reset) => { await client.connect() await client.query('BEGIN') await client.query('CREATE TABLE IF NOT EXISTS couchwarehouse_checkpoints (id SERIAL PRIMARY KEY, tablename TEXT, seq TEXT)') await client.query('COMMIT') }
db.connect((err, client) => { if (err) throw err; console.log('Connected to database', db.database); db.end(); });
client1.connect(function(err, client, done) { client1.query(userSql, function(err, result) { if (err) { console.log('error: ', err); process.exit(1); } console.log(`User '${userName}' created successfully:`, result); }); });
let createDb = () => { client.connect() return client.query('CREATE DATABASE postapp') }
async function startServer () { await client.connect() console.log('db connected') terminus(http.createServer(app), { logger: console.log, signal: 'SIGINT', healthChecks: { '/healthcheck': onHealthCheck }, onSignal }).listen(3000) }