Questions tagged [node-pg-pool]

A connection pool for node-postgres node.js

https://github.com/brianc/node-pg-pool A connection pool for node-postgres node.js

48 questions
0
votes
1 answer

Why does one loop style give me an error but the other doesn't?

Preface: I am using typescript and node-pg (Postgres for node) to populate an array of promises and then execute them all using Promise.all(). When iterating over an array of numbers and pushing queries into an array, I get an error if I loop over…
Tank12
  • 323
  • 3
  • 12
0
votes
1 answer

Handling query errors with node-pg

I'm trying to insert two queries into my postgres database as follows: const insertLineItemDB = (request, response) => { const { wo_num, description, due_date, cost } = request.body const query1 = 'INSERT INTO workorders (wo_id, due_date,…
NicLovin
  • 317
  • 3
  • 20
0
votes
2 answers

How to add variable into JSON path

This is the query I am using: app.get("/items/:data", async (req, res) => { const { data } = req.params; query = ` SELECT items.discount FROM items WHERE items.discount @? '$[*] ? (@.discount[*].shift == $1)' …
Ulvi
  • 965
  • 12
  • 31
0
votes
0 answers

Trouble solving: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

I'm working on a simple web app using node-pg and express.js with a login page and a dashboard that displays some data from a database. The dashboard and all it's data loads fine initially using the following function after the user inputs their…
NicLovin
  • 317
  • 3
  • 20
0
votes
1 answer

How to create multiple queries in a single GET request

I am using node-pg and would like to make multiple queries within a single GET request. For example consider I make two queries like so: const getSomeInfo = (request, response) => { pool.query('SELECT * FROM jobs', (error, results) => { …
NicLovin
  • 317
  • 3
  • 20
0
votes
1 answer

unable to get correct error with Node-PG pool.query

I'm a total beginner attempting to make social media site with the PERN stack and I'm having trouble with my delete request, while debugging with Postman. Basically, I've logged in as user X, created a post, logged out, THEN logged in as user Y and…
0
votes
2 answers

nodejs pg-pool doesn't seem to be pooling

I've been trying to get nodejs to pool postgresql connections in my app unsuccessfully. This is an independent test I did: const config = require('../config/project_config.json'); const Pool = require('pg-pool'); var pool = new Pool({ user:…
0
votes
2 answers

How to insert multiple objects into one table?

There's a table entityLinks and I would like to insert multiple values by one query. The table was defined using this query: CREATE TABLE entityLinks( id INTEGER NOT NULL references posts(id) ON DELETE CASCADE, tag VARCHAR(255) NOT NULL references…
embu
  • 1
  • 2
0
votes
1 answer

How to add to Postgresql where clause when number of valid variables is initially unknown?

Hello dev community :) Stack: nodejs, Postgresql, npm: pg How can I add to my query 'and' statement in 'where' clause for variables which can be valid or can be undefined? Example `select col1, col2 from table where col1='${test1}' ` <-- add here…
Ivan Kolyhalov
  • 902
  • 11
  • 16
0
votes
0 answers

Pg-promise stops opening new connections, no error message

In my express-js app pg-promise sometimes stops accepting connections, even for simple things as a select now() query. It's very random. I can run a load test and have 100 concurrent requests run for 10 seconds with response times of 100+ req/s.…
Johan Nordberg
  • 3,621
  • 4
  • 33
  • 58
0
votes
0 answers

postgres returns only one record , many records needed

so i'm going through this app i did the api request succesfully but in my table i have more than one record and the query returns me only the first column router.get('/OnePost', (req,res)=>{ jwt.verify(req.token, 'configSecret', (err, authData)…
ana bel
  • 177
  • 1
  • 15
0
votes
0 answers

How to insert a record into Postgres from Node.js? node-pg not well documented

1. Summarize the problem I need to insert data into Postgres from node-pg. There is a primary key column created with 'serial'. The node-pg documentation is sorely lacking, most tables I see in production have an auto-increment primary key, and a…
user10664542
  • 1,106
  • 1
  • 23
  • 43
0
votes
1 answer

many queries postgres (node), no parallel queries?

I am running a node server with the postgres-node (pg) package. I wrote a program, which requests n-queries (for instance 20,000) at once to my postgres database. When I do this with several clients who want to query 20,000 at once too, there is no…
André
  • 1,078
  • 10
  • 22
0
votes
0 answers

node postgres connection perfomance improvement

I am writing my backend using nodejs (express), and my database is PostgreSQL. I am using node-postres (pg) to connect to the postgres database. Currently I am using the pg.Pool concept, so that I will have clients connected to serve the…
user2733130
  • 157
  • 3
  • 16
0
votes
2 answers

How to increment postgres table column after selecting the current value qith Node pg?

I am creating an app that has a user, question, answer, comment, and voting tables. Not sure if it's good decision, but I've decided to make the voting table into a join table containing IDs of all the other tables instead of having every other…
Dean
  • 95
  • 1
  • 9