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
0 answers

pg-promise reads integers as string, even after being parsed

I'm having the following error: I have a post form to insert some values to a postgres database using pg-promise. Those values are being converted to integers on the server. But when I try to insert the values to postgres, it says: invalid input…
Blinhawk
  • 379
  • 2
  • 7
  • 19
0
votes
1 answer

Inserting records in PostgreSQL with 2 varying parameters from an array

I'm trying to bulk insert in postgresql from an array. What I'm currently doing is the following inside of a loop. INSERT INTO table_name ( first, second, third, forth ) VALUES ( $1, $2, $3, $4 ) There are around 8 to 9 other fields, and only 2…
Tarek Deeb
  • 168
  • 9
0
votes
2 answers

Pg-promise inserts/transactions not working within async queue

I have found a lot of things related to the use of pg-promise and await/async but nothing that quite answers my issue with async (the node/npm package) and in particular the interaction between async.queue and pg-promise queries. My issue: I need to…
0
votes
0 answers

pg-promise join array with promise result

I've spent the last few days learning node.js and pg-promise, and I'm trying to optimize my code to be as efficient and fast as possible. I'm not sure if I'm using pg-promise correctly, but I've been reviewing these posts and guides. Nested queries…
Thad
  • 1
  • 3
0
votes
1 answer

return does not terminate a promise/then chain

I have the following code that I use to signup users. const pgp = require('pg-promise')(); const crypto = require('./crypto.js'); const db = pgp(connection); const querySelect = (text, params) => { const s = pgp.as.format(text, params); …
slevin
  • 4,166
  • 20
  • 69
  • 129
0
votes
0 answers

How pg-promise handles multiple clients in the same app

I am creating code using just the pg module, where I have a general function for executing queries. This function can create a client on the spot if it doesn't take an already existing client as an argument. Or it can use an already existing client …
slevin
  • 4,166
  • 20
  • 69
  • 129
0
votes
1 answer

How to use pgp.as.format for a transaction

Is it possible to use pgp.as.format to see raw postgres queries generated by a transaction db.tx(t => ...)? I can't figure out the syntax for this use-case.
Naisheel Verdhan
  • 4,905
  • 22
  • 34
0
votes
0 answers

On batch inserts make sure checkid/promise resolves before next call

Throwing this out there but I know vitaly is such a hawk that he'll probably give me the answer or at least a solid hint ;) I am basically uploading a batch of records and checking if the Company has already been added to a Company table. If not,…
Barry Smith
  • 105
  • 1
  • 2
  • 10
0
votes
0 answers

Inserting with subqueries using pg-promise

I have an insert on postgres 10 that uses subqueries to look up foreign keys on a unique column, like this (just an illustration example): CREATE TABLE company (id SERIAL PRIMARY KEY, name VARCHAR(50) NOT NULL, companyCode CHAR(4) NOT NULL…
0
votes
1 answer

Trying to GET json data, getting "not a function" error

I'm creating a programmer job board app and I'm trying to display json data on my main page. At some point I'll render it, but for now I'm just trying to get it to show up in json form so that I know it works. I'm able to connect to the server, but…
Tsardines
  • 883
  • 2
  • 8
  • 17
0
votes
0 answers

Creating To Do app, can't render '/new' to browser and "data" in file isn't defined

I'm working on a simple To Do app (using pg-promise, embedded js, node.js, and regular JS) and I'm having trouble getting the create functionality to work. I'm able to view every post, view only one post, and delete posts (although this part can…
Tsardines
  • 883
  • 2
  • 8
  • 17
0
votes
1 answer

Embedded JS (ejs) isn't rendering data to browser

I'm working on a simple To Do app using express, node, pg-promise, and ejs. I created a database and I can't get the contents to show up in the browser. The weird thing is that when I inspect the browser it recognizes the shape of each task, but…
Tsardines
  • 883
  • 2
  • 8
  • 17
0
votes
2 answers

Any way to transform a data type when using pgp.helpers.insert?

Begging newbie forgiveness here I've gotten a bunch of POC's working but now that I am working on my production dataset the CSV file I am parsing has the ID field as a string but in Postgres it's an Integer. The basic error I get is: Unhandled…
Barry Smith
  • 105
  • 1
  • 2
  • 10
0
votes
1 answer

pg-promise: what would be the best way to obtain multiple results sets where order matters

here is my naive code: db.projects.find_one(project_id, user_id) .then(project => { if (!project) { req.flash('info', 'Project not found'); res.redirect('./projects'); } else { …
0
votes
1 answer

pg-promise format default - not existing Property to null

I would like to be able to have the formatting.formatValue function convert undefined into null. But there does not appear to be a way that I can set the default function from the initOptions given to pg-promise as pgFormatting is a boolean, format…
Liam Mitchell
  • 1,001
  • 13
  • 23