Questions tagged [pg-promise]

Complete access layer to node-postgres via Promises/A+.

Built on top of node-postgres and its connection pool, this library translates their callback interface into one based on Promises/A+, while extending the protocol to a higher level, with automated connections and transactions management.

In addition, the library provides:

  • its own, more flexible query formatting;
  • event reporting for connectivity, errors, queries and transactions;
  • declarative approach to controlling query results;
  • support for all popular promise libraries.
521 questions
0
votes
1 answer

Get executed SQL statement from pgPromise query result

I'm writing an API that does queries over multiple postgres databases using node and pg-promise. I'm interested in getting the executed SQL statement from query result. Something like pg-monitor outputs to console. I've set up pg-monitor and…
0
votes
0 answers

How to do relational table updation using transaction?

I am using pg-promise for my project. I have a scenario, where I have to insert in two tables, where the 2nd table needs the pk of 1st table as fk. How to do this using pg-promise transaction ? In docs I could only see non relational operations, is…
0
votes
1 answer

Unit Test Functions Connecting to a Postgres DB

I am using mocha, nodejs and pg-promise connecting to a Postgres db. I am wondering how can I unit test a function that executes a DML? This is just a simple example: export function insertUser(db, { firstName, lastName }) { db.one(` INSERT…
Chris
  • 87
  • 2
  • 8
0
votes
1 answer

Same name attributes in select list in pg-promise

Is it possible to get the same name attributes in the select list (as JSON deduplicates them)? For instance: CREATE TABLE t1 ( id int; ); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); CREATE TABLE t2 ( id int; ); INSERT INTO t2…
igorludi
  • 1,519
  • 2
  • 18
  • 31
0
votes
2 answers

Calling a Postgres db function in Node API

I am trying to call this Postgres function core.get_age(bigint) in my queries.js function getAge(req, res, next){ var customer_id= parseInt(req.params.customer_id); db.one('SELECT * FROM core.get_age($1)', customer_id) …
OLDMONK
  • 382
  • 2
  • 7
  • 25
0
votes
1 answer

Invalid status code : 0 in node.js API

I am building a simple api in node and express with postgre as Db following a tutorial.I am still learning and new to this tech.I followed everything as said and gave full permission to postgre thinking about issue with my db.But when i check it…
OLDMONK
  • 382
  • 2
  • 7
  • 25
0
votes
0 answers

How to use pg-promise?

I have a scenario in which i have used 'async' library in a manner as below. async.series([function (cb) { dbWeb.saveOrderForm(chain.toString(), function (err, data) { if (err) { cb(err); …
0
votes
2 answers

Simple Check Function with node.js, pg-promise

I am trying to write a simple check() function following this example. The function successfully prints out "True!" but the return value of the function is undefined when I do…
cpage
  • 119
  • 6
  • 27
0
votes
0 answers

Accessing pg-promise module in webworkers-thread

In am in need of using pg-promise library in Node.js. It is known that we can't include require() within webworker-threads. Although the author of webworker-threads posted a similar kind of question, one can take the advantage of Browserify to…
0
votes
0 answers

Cant able to fetch the data from postgres sql anonymous block in Nodejs using pg npm

I was trying to fetch the data from postgres sql using nodejs. I have been using npm pg to establish the connection to database. Using select query trying to fetch all the data from postgres but PostgreSQL returns the data in anonymous block. I was…
GunasekaranR
  • 169
  • 1
  • 11
0
votes
0 answers

How to deal with Postgres user authentication in pg-promise?

My desktop application uses Postgres authentication and keeps permanent connection to Postgres, so every query is executed by specific user. All queries send by a single instance of the application have to be executed in the same Postgres session. A…
Adam Piotrowski
  • 2,945
  • 3
  • 20
  • 23
0
votes
1 answer

Node - Throw SOAP error on an promise catch block

I am developing an SOAP Server in NodeJS (v6.9.4) using the SOAP library. I have to request some data from a Postgres database. I choose to use the pg-promise lib. SAOP Services are implemented like this : TestConnection: function (args, cb,…
Spawnrider
  • 1,727
  • 1
  • 19
  • 32
0
votes
3 answers

how to chain statements together using promises

I'm new to node, and learning all about promises, and pg-promise specifically. This is what I want to do using Express and pg-promise: check email, if not found check username, if not found create a new user. return user id I've got my repo set…
Coco
  • 1,550
  • 3
  • 24
  • 43
0
votes
1 answer

pg-promise transaction response

So I'm a little stuck here. I have an object such as: var lineItems = [ { id: 1, quantity: 10 }, { id: 2, quantity: 15 }, { id: 4, quantity: 22 } ] now what I need to do is loop through…
0
votes
0 answers

Postgresql [ReferenceError: (somevalue) not defined]

Here's my code containing PostgreSql query using pg-promise: var db = require('/pg-connection'), PQ = require('pg-promise').ParameterizedQuery; var fullname = 'username', email = 'UniqueEmailHere', password = 'userPassword', …
Adil
  • 21,278
  • 7
  • 27
  • 54