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
5
votes
2 answers

Multiple rejects from promises in Promise.all, what exactly happens?

Promise.all([iterable]) is all or nothing, meaning that the promise it returns resolves when every promise in the iterable resolves, or rejects as soon as one of the promises rejects, with the reason of the first promise that rejects (doc). But what…
smellyarmpits
  • 1,080
  • 3
  • 13
  • 32
5
votes
2 answers

Reusing pg-pool via module exports

After reading the docs: https://github.com/brianc/node-pg-pool, I am slightly concerned about reusing the new Pool() method. The docs suggests that I need to place the new Pool() before exports and return it like so // db.js const pool = new…
Antartica
  • 125
  • 9
4
votes
1 answer

how to disconnect a pool in pg module

So, I use the pg module in node 8.11.1 / express 4.16.3 / pg 7.4.2 I try to use the pool for my front-end (just selects) and the examples are somewhat confusing. In connecting it uses just a new Pool and then it shows that I have to do…
codebot
  • 517
  • 8
  • 29
  • 55
3
votes
1 answer

pg pool - whats right way to utilise pg pool with timeout functionality

I need some help regarding pg npm. I have read many write ups and examples and have got totally confused about using the pg pool in a right way. Many of the articles are old which I read. I would like to show you some of my code and how I have…
Viddesh
  • 441
  • 5
  • 18
2
votes
1 answer

PERN stack: Iterating through array of data, my call to my database is not going through for every data record

I have been trying like crazy to find a solution to my problem, but nothing seems to work and I don't know where I am going wrong. I am creating an app using the PERN stack, and I have an array of data with a length of 24. I iterate through my data…
2
votes
1 answer

Setting up pg-pool connection on Next.js initialization: ERROR: "Can't resolve 'fs'

I'm trying to use npm pg with pg-pool in my Next.js application. I'm new to pooling connections but I gathered that I need to establish a pool connection whenever my Next.js server is initialized and I need to pass that connection as a module around…
2
votes
1 answer

Using Jest to test anonymous function inside 3rd party module

I have a pretty simple module that use pg (node-postgre lib) module, I'd like to implement a Jest test and while mocking the pg module I would like to run it's callback function to see the console.log runs and my callback is being invoked I have…
OfirYaron
  • 157
  • 1
  • 9
1
vote
1 answer

How to Send and Receive ByteA Images with PostgreSQL, node-pg and ExpressJS

This is my images table in PostgreSQL: CREATE TABLE IF NOT EXISTS images ( ---------------------------------------------------- id UUID NOT NULL DEFAULT uuid_generate_v4(), ---------------------------------------------------- …
Philippe Fanaro
  • 6,148
  • 6
  • 38
  • 76
1
vote
0 answers

Type intersection issue when switching to TypeScript 4.8

I'm moving from TypeScript 4.5 to 4.8 and stumbled upon the following issue. I have these two types: export interface IQueryConfig { text: string; values?: any[]; } export interface IQueryResult { rows: T[]; rowCount:…
tdranv
  • 1,140
  • 11
  • 38
1
vote
1 answer

PostgresSQL Insert error: duplicate key value violates unique constraint "todo_task_key"

I am trying to insert some values to my table called todo, i've Postico gui open, which I can see the table visually on my screen better. The insert query was successfully, base off the console.log, that states "Data insert successful", which it…
Palm
  • 360
  • 2
  • 17
1
vote
0 answers

pg-promise not reconnecting clients in pool after broken connection

I'm using pg-promise (and the underlying pg-pool lib). When I pull the plug on my pg database briefly (break TCP connections), I get connect ETIMEDOUT errors (expected) however it is taking a very long time for the pool to re-establish a connection.…
rynop
  • 50,086
  • 26
  • 101
  • 112
1
vote
1 answer

Null value in column "title" of relation "blog" violates not-null constraint

I'm building a little blog using express js for the backend, but I'm facing an issue: I get this error in the console null value in column "contentblog" of relation "blog" violates not-null constraint Code: const connection =…
1
vote
0 answers

why do connections remain in pg_stat_activity after a client process has been killed?

I'm debugging a "sorry, too many clients already" issue with Postgres and just learned about the pg_stat_activity table. I noticed there are a lot of dangling idle connections in it for nonexistent PIDs, here are just two examples: datid | …
Andy
  • 7,885
  • 5
  • 55
  • 61
1
vote
1 answer

How do I parameterize a Postgres array value in Node / pg-pool

I am querying an array column (style text[]) using the contains operator @>. My raw query is: SELECT * FROM songs WHERE style @> '{Acoustic}' When I drop this into node (using pg-pool) and attempt to parameterize it, the braces surrounding the…
rotarydial
  • 2,181
  • 2
  • 23
  • 27
1
vote
0 answers

How to create a dynamic query function in nodejs pg module?

For example: const update = ({title, price, imageUrl, description, whereId, whereTitle }) => { return db.query( `UPDATE products SET title=$1, price=$2, "imageUrl"=$3, …
calvindio
  • 347
  • 3
  • 11
1
2 3 4