Node-postgres is a postgresql client module for node.js applications to interact with postgresql databases.

learn more… | top users | synonyms

0
votes
2answers
21 views

Handling Postgres Error Message To Perform Correct Query

I am using pg and node.js. When a user logs in using the auth0 widget I am passing the email it returns and checking my database to see if the user exist. If the user does not exist I am inserting ...
0
votes
1answer
25 views

slow Postgres query, possible indexing fix?

I am writing a web app that uses eight Postgres queries on a quite small database (circa 300 records). There is only one query that is repeatedly unsatisfactory. It seems strange to me that the bad ...
0
votes
1answer
8 views

Specify timeout to connect to pg database using node-postgres package?

I'm trying to connect to a postgres database. If it takes more than 1/2 a second to connect(), I'd just like to timeout and assume it's unavailable. Unfortunately, if I change the config to an ...
0
votes
1answer
46 views

Node ORM for Oracle and PostgreSQL

I'm on the look out for a node ORM that works well with both Oracle and PostgreSQL. I see that Waterline and Sequelize do not have built in support for Oracle. Sequelize-Oracle is available though. ...
2
votes
3answers
318 views

Node-postgres: named parameters query (nodejs)

I used to name my parameters in my SQL query when preparing it for practical reasons like in php with PDO. So can I use named parameters with node-postgres module? For now, I saw many examples and ...
5
votes
2answers
94 views

How to optimize Postgresql max_connections and node-postgres connection pool?

In brief, I am having trouble supporting more than 5000 read requests per minute from a data API leveraging Postgresql, Node.js, and node-postgres. The bottleneck appears to be in between the API and ...
0
votes
0answers
22 views

How to setup pg-promise when number of requests greater then available connections?

I've a PostgreSQL database where I can simultaneously open 60 connections, but at any given time I need to serve 100-120 requests. According to manuals of pg-promise which is based on node-postgres ...
0
votes
0answers
22 views

node-postgres connection issue

I have tried connecting my application using npm "pg" library to connect my ExpressJS application to my local Postgre db. I don't really know what I've done wrong. But here's a piece of my code in my ...
0
votes
1answer
21 views

node-postgres LEFT JOIN query

I am attempting to effect a join query in node-postgres (pg) with the following function but am getting a syntax error. The problem is the join query, everything else works fine. What is the correct ...
0
votes
1answer
26 views

node-postgres, express with pg-pool, sending data to Angular frontend

I am pooling connections to my Postgres DB with pg-pool. I am having trouble, however, sending the results of my queries to the frontend. I assumed that I could use res.send as usual but it is not ...
0
votes
1answer
21 views

Postgres md5 authentication from Node

I'm trying to connect to postgres via node using the md5 authentication method. My pg_hba_conf file looks like this: "local" is for Unix domain socket connections only local all all ...
0
votes
1answer
91 views

node-postgres vs pg-promise for Nodejs Application

I'm going to build a Nodejs application with Postgresql as back end. I'm not going to use ORMs like Sequelize due to poor documentation and performance problems or any other ORM - ORM is an anti-...
2
votes
1answer
52 views

On node how to you perform an insert if doesn't exists

My rest api calls Put request to this function to create firebase token on Postgre-sql. However, I realized whenever the token gets refreshed a new row will be added for the same user. How do I make ...
0
votes
0answers
70 views

Node-postgres parameterized queries with array parameter

I'm trying to execute this PSQL query to call a function and get a list of ids back. [This function works when run in PGAdmin as it should, verified by the ids coming back.] SELECT get_dataids( '...
25
votes
5answers
11k views

node-postgres: how to execute “WHERE col IN (<dynamic value list>)” query?

I'm trying to execute a query like this: SELECT * FROM table WHERE id IN (1,2,3,4) The problem is that the list of ids I want to filter against is not constant and needs to be different at every ...
0
votes
0answers
45 views

Promise based node-postgres request under Node.js

I'm trying to implement a promise-based approach to accessing a PostgreSQL database. This is the original code: // ./sql/config/pgQuery.js module.exports = (text, values, cb) => { pool.connect((...
1
vote
1answer
32 views

Get time that all query finished

function runAll(){ for (var i = 0; i < Math.random(); i++) { pool.connect(function(err, client, done) { client.query("update box set gamer_id=null where box_id=$1; ", [i],...
10
votes
0answers
212 views

PostgreSQL tuple format

Is there any document describing the tuple format that PostgreSQL server adheres to? The official documentation appears arcane about this. A single tuple seems simple enough to figure out, but when ...
2
votes
0answers
77 views

Timestamptz, same point in time but different representation for same query with 'set local time zone'

I am trying to build my web app that will store the data on a PostgreSQL database server running on some location on Earth and will have users connecting from other locations, so probably different ...
0
votes
3answers
60 views

PostgreSQL lead() issue with camelCase column

So I'm trying to query a time card table whose structure is like this employeeId | clockInTime| clockOutTime -----------+------------+-------------- 555 | 1462797450 | 1462785465 555 | ...
5
votes
3answers
3k views

node-postgres: how to prepare a statement without executing the query?

I want to create a "prepared statement" in postgres using the node-postgres module. I want to create it without binding it to parameters because the binding will take place in a loop. In the ...
0
votes
1answer
100 views

Nodejs server disconnecting after idle for too long (ECONNRESET)

Good day, I have the following issue: my node.js server which is running node-postgres to communicate with a database gives the error read ECONNRESET when a client asks for it to query the database. ...
2
votes
1answer
102 views

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 ...
1
vote
1answer
28 views

Knex saves date incorrectly

I have a date field set with table.date('day'); in knex schema. When I insert it with knex('table_name').insert({ someOtherData, day: '2016-08-14'}) and then use knex.select('day').from('table_name') ...
2
votes
1answer
58 views

How to convert MySQL-style question mark `?` bound parameters to Postgres-style `$1` bound parameter

I am converting an existing project from MySQL to Postgres. There are quite a few raw SQL literals in the code that use ? as a placeholder, e.g. SELECT id FROM users WHERE name = ? ...
0
votes
1answer
28 views

node-postgres: Update more than one record at once

I'm building an app in node.js using node-postgres. I don't know how to update more than one record at once. Here is my code: var status = 20; var id = [23,12,43]; pool.connect(function(err, client, ...
0
votes
1answer
37 views

PostgreSQL node.js prepared statements maximum bindings

I am trying to do some big bulk inserts to Postgres via node-postgres When the bindings array exceeds 65536 values then passes to postgres the rest of values and when the query it runs I take the ...
0
votes
0answers
89 views

Not able to connect to PostgreSQL via NodeJS

Below is the connection details exports.DB_NAME = "postgres"; exports.DB_USERNAME = "abcd"; exports.DB_PASSWORD = "abcd1234"; exports....
5
votes
3answers
4k views

Use node-postgres to get Postgres “timestamp without timezone” in utc

I've got some timestamps stored as the Postgres type timestamp without time zone. I'll use the timestamp 2013-12-20 20:45:27 as an example. I'm intending that this represent a UTC timestamp. In psql,...
1
vote
4answers
2k views

How to make a synchronous query (blocking call) with node-postgres?

While booting my Node.js app, I want to make a couple of synchronous calls to the PostgreSQL database to check some things before continuing the control flow. How can I achieve this using the node-...
1
vote
1answer
69 views

Postgres: Cannot connect from NodeJS (PG) with md5

Node v6.2 on Windows 10; PG (node-postgres) v4.4.2 Postgres 9.5 on Ubuntu 14.04 Trusty VirtualBox I'm using the PG (node-postgres) module to connect to Postgres on Ubuntu in a virtual machine. I was ...
0
votes
1answer
93 views

(node) warning: possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit

I am using pg node module for connecting database. I have been creating multiple connection for each DML operation. when continuous query execution takes place I got warning message as "(node) ...
0
votes
0answers
22 views

Can I use node-postgres or sequelize with nginx?

Will there be any problem with the multiple instances that nginx might create of my webserver and the connection pool? I'm asking because of this particular quote I found on sequelize documentation: ...
1
vote
3answers
41 views

(node-postgres, pg) Proper insertion of table name

How does one correctly provide the table name if the name can be dynamically determined and still prevent SQL injection attacks? For example: The following works but I believe is insecure: dbclient....
2
votes
1answer
45 views

How to get data that was createdAt or updatedAt 30 seconds from the the current time PostgreSQL

I'm trying to access data from a table that was created or updated data 30 seconds from the current time. Does anyone have any good idea of how to do this efficiently? I'm using node.js and pg package ...
0
votes
0answers
26 views

node+node-postgres+postgres insert into from select not working in trigger

I have a problem I do not understand. I have a trigger on insert in one of my tables. This trigger is working perfectly if I insert the data in my table from the psql command line. Now I normally do ...
1
vote
2answers
104 views

Omiting column names / inserting objects directly into node-postgres

I'd like to pass dictionaries with column names as keys, thus avoiding declaring the column names within the query itself (typing them directly). Assume I have a table User with 2 column names: ...
1
vote
2answers
149 views

postgres:get executable query from query with parameters

Is there any way to get executable query from query with $ parameters.Actually its weird but i want to store executable query in database.A complete query without parameters($1,$2,$3) i am using node-...
4
votes
3answers
1k views

How do I properly insert multiple rows into PG with node-postgres?

A single row can be inserted like this: client.query("insert into tableName (name, email) values ($1, $2) ", ['john', '[email protected]'], callBack) This approach automatically comments out any ...
-1
votes
1answer
97 views

for loop inside query

I have this in mongo: //fill QueryString collection.find({"myID" : {$in:QueryString} },{}).toArray(function(err, Stuff) { ... var flag = true; for (var i=0; i<Stuff.length; i++) { //if ...
0
votes
1answer
44 views

from mongo to postgresql - error: syntax error at or near “array_to_string”

I am trying to learn databases and nodejs. I want to ask how can I translate the following from mongod to postgresql using nodejs. //fill QueryString collection.find({"myID" : {$in:QueryString} },{})...
3
votes
2answers
2k views

node-postgres 'event emitter style' vs 'callback style'

node-postgres states the following: node-postgres supports both an 'event emitter' style API and a 'callback' style. The callback style is more concise and generally preferred, but the evented ...
2
votes
4answers
2k views

Mass insert into Postgres with brianc/node-postgres

I have the following code in nodejs that uses the pg (https://github.com/brianc/node-postgres) My code to create subscriptions for an employee is as such. client.query( 'INSERT INTO ...
0
votes
1answer
128 views

Node-Postgres: program does not work after 30 seconds while using Express, no problems without Express

I am using node-postgres to connect to a Postgres database from NodeJS; it gives a strange error Cannot read property 'rows' of undefined after running the program for 30 seconds (after the first ...
3
votes
1answer
504 views

Why can't I delete from db using node-postgres?

Is there something special i need to do with a parameterized query? the following seems to succeed (i'm using a promise-ified client.query see end), console.log('cancel for', data); var ...
1
vote
1answer
60 views

out parameter result returns by node pg module - postgresql

I have created a procedure in postgresql as below. CREATE OR REPLACE FUNCTION public.functiontest2( IN data numeric, OUT result numeric, OUT result1 numeric) RETURNS record AS $BODY$ ...
2
votes
2answers
251 views

Node calling postgres function with temp tables causing “memory leak”

I have a node.js program calling a Postgres (Amazon RDS micro instance) function, get_jobs within a transaction, 18 times a second using the node-postgres package by brianc. The node code is just an ...
0
votes
0answers
44 views

How to print Postgresql schema via node-postgres or Knex.js

How to print Postgresql schema via node-postgres or Knex.js? Ideally, I would like to have a schema.sql that is generated by Knexjs migration like what Ruby's ActiveRecord does.
9
votes
2answers
6k views

node-postgres with massive amount of queries

I just started playing around with node.js with postgres, using node-postgres. One of the things I tried to do is to write a short js to populate my database, using a file with about 200,000 entries. ...
-1
votes
3answers
196 views

node-postgres : query not executing in sequence

i have kept insert & update code in 2 different files and based on condition always insert should execute first and then update.but somehow update executes first then insert test.js : ...