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

How to lock table with pg-promise

I have db.result('DELETE FROM categories WHERE id = ${id}', category).then(function (data) { ... and db.many('SELECT * FROM categories').then(function (data) { ... initially delete is called from one API call and then select on following API call,…
user2846569
  • 2,752
  • 2
  • 23
  • 24
0
votes
1 answer

pg-promise: passing res to promise

I am trying to figure out how to pass res parameter (from post request) to the promise chain. I have following code: router.post("/", (req, res) =>{ let email = req.body.username; let pass = req.body.password; conn.any("SELECT * FROM users WHERE…
0
votes
0 answers

When using pg-promise, how do you set a query to timeout after a time/cancel the query?

We have a query we want to run with pg-promise, but we want to cancel it if it takes to long to run. Is there a method in PGP to do this? Edit: I understand this is usually considered a hack, however I want to fetch roughly 100,000 rows out of 100…
Robert Mennell
  • 1,954
  • 11
  • 24
0
votes
1 answer

Syntax error integer

There is an Angular 4 client side Nodejs-Express back end and PostgreSQL database. The problem is that if I want to send data to server ( in my submodule, what is a todo function ) the backend send me the next: My error message is: POST…
0
votes
1 answer

Determine when an SQL alias can be an open name

What would be the highest-performing implementation to determine if a string that represents an SQL alias needs to be wrapped in double-quotes? Presently, in pg-promise I am wrapping every alias in double-quotes, to play it safe. I am looking to…
vitaly-t
  • 24,279
  • 15
  • 116
  • 138
0
votes
1 answer

pg-promise multi-row update with geom and json columns

I love pg-promise but am having difficulty inserting multiple rows into a table that has both geom and json columns. I'm not sure of the syntax. I want to be able to pass in an array of objects for example: [{pt_title: 'title1', lat:…
Coco
  • 1,550
  • 3
  • 24
  • 43
0
votes
1 answer

pg-promise upsert on postgresql 9.4.11

I've searched extensively and I've not been able to solve this simple issue. I'm programming in nodejs, and using pg-promise to store my JSON file dynamically into a postgres 9.4.11 database (I'm not allowed to upgrade the DB). My JSON contains…
0
votes
0 answers

pg promise nest tables results when selecting from multiple tables

I have query that gets data from multiple table. I am using pg-promise with node js. My old project database was MySql and I used node [mysql][1] whick allowed me to get nested result from query like this: var nestingOptions = [ {…
0
votes
1 answer

Nodejs application hangs on heavy requests

I am using, Nodejs express server with pg-promise. I have some queries in the database which takes alot of time to return result. For such queries I set a timeout for 3sec which fails the promise, if the query pg-promise query takes longer and the…
Naufal Khalid
  • 409
  • 2
  • 6
  • 11
0
votes
1 answer

Can I relation multiple 'where' condition in pg-promise?

I using pg-promise with express 4 on node 8.2.0. Inside that I want to concatenate where condition. But, I couldn't find that way. Please help me. I expect this. let ids = [10, 20, 30] db.query('SELECT * FROM table WHERE id = {something-way}',…
0
votes
1 answer

Module export of pg-promise object derived from promise chain

We're using HashiCorp's Vault to store database connection credentials, then constructing the connection string for pg-promise from those. The 'catch' is that the Vault details are provided from a Promise wrapper, due to request callbacks to the…
sqldoug
  • 429
  • 1
  • 3
  • 10
0
votes
1 answer

Relation does not exist error with pg-promise and postgresql?

I am using pg-promise on Node 7.2.1 with PostgreSQL 9.4. I am using the code below to connect to the PostgreSQL server: // pg-promise connection elements. // Database initialization options. const pg_options = { // Initialization…
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
0
votes
0 answers

How do I get pg-promise to return many rows in order?

I am using the following query in pg-promise: SELECT id, title, price FROM ${schema~}.ebooks WHERE isbn = ${isbn}; pulling the data from pg with: db.query(sql.ebooks.get, { isbn: isbn }) When I look at the row in pg they are in the order that I…
M.Holmes
  • 403
  • 1
  • 7
  • 22
0
votes
1 answer

TypeError: Invalid connection Details (PG-Promise)

So I'm trying to solve an issue that PG-Promise is giving me, but I'm not entirely certain as to why. I'm very certain that I set up the database and environment for it correctly, and have properly seeded and tested the database locally. If needed…
Benji Durden
  • 313
  • 3
  • 6
  • 17
0
votes
2 answers

Mocking database when testing microservice functions

I have created a basic NodeJS micro-service with pg-promise. I have created the routing file (index.js) containing the APIs via express: var express = require('express'); var router = express.Router(); var db =…
Anto
  • 4,265
  • 14
  • 63
  • 113