How to use the pg-promise.ParameterizedQuery function in pg-promise

To help you get started, we’ve selected a few pg-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiskHQ / lisk-sdk / db / repos / transactions_old.js View on Github external
this.transactionsRepoMap[transactionTypes.DELEGATE] = 'transactions.delegate';
	this.transactionsRepoMap[transactionTypes.IN_TRANSFER] =
		'transactions.inTransfer';
	this.transactionsRepoMap[transactionTypes.OUT_TRANSFER] =
		'transactions.outTransfer';
	this.transactionsRepoMap[transactionTypes.MULTI] =
		'transactions.multisignature';
	this.transactionsRepoMap[transactionTypes.SIGNATURE] =
		'transactions.signature';
	this.transactionsRepoMap[transactionTypes.VOTE] = 'transactions.vote';
}

var Queries = {
	count: 'SELECT COUNT(*)::int AS "count" FROM trs',

	countById: new PQ('SELECT COUNT(*)::int AS "count" FROM trs WHERE "id" = $1'),

	countList: function(params) {
		return [
			'SELECT COUNT(*) FROM trs_list',
			params.where.length || params.owner ? 'WHERE' : '',
			params.where.length ? `(${params.where.join(' ')})` : '',
			// FIXME: Backward compatibility, should be removed after transitional period
			params.where.length && params.owner
				? ` AND ${params.owner}`
				: params.owner,
		]
			.filter(Boolean)
			.join(' ');
	},

	list: function(params) {
github LiskHQ / lisk-sdk / test / functional / system / blocks / process / on_receive_block.js View on Github external
sequenceCb => {
				db
					.query(
						new PQ('SELECT "id" FROM blocks ORDER BY "height" DESC LIMIT 10;')
					)
					.then(rows => sequenceCb(null, rows))
					.catch(err => sequenceCb(err, []));
			},
			(err, rows) => {
github LiskHQ / lisk-sdk-examples / test / integration / blocks / process / on_receive_block.js View on Github external
sequenceCb => {
				db
					.query(
						new PQ('SELECT "id" FROM blocks ORDER BY "height" DESC LIMIT 10;')
					)
					.then(rows => sequenceCb(null, rows))
					.catch(err => sequenceCb(err, []));
			},
			(err, rows) => {
github LiskHQ / lisk-sdk / test / integration / blocks / process / on_receive_block.js View on Github external
sequenceCb => {
				storage.adapter.db
					.query(
						new PQ('SELECT "id" FROM blocks ORDER BY "height" DESC LIMIT 10;')
					)
					.then(rows => sequenceCb(null, rows))
					.catch(err => sequenceCb(err, []));
			},
			(err, rows) => {