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

learn more… | top users | synonyms

1
vote
0answers
33 views

node-postgres simple SELECT is becoming extremely slow (PostgreSQL)

I'm developing an server-side app for mobile game backed with postgresql and I'm using pg with Knex("pg": "6.1.2" and "knex": "0.12.6"). Not so long ago I faced a problem with select perfomance ...
0
votes
1answer
47 views

Express/node-postgres pass an object with multiple values to insert query

I'm serializing a form and sending with jQuery AJAX the data to an express route: The object sent as arrobj is for example: { col1: [ 'one', 'two', 'three' ], col2: [ 'foo', 'bar', 'baz' ] } ...
1
vote
1answer
48 views

Exclude “grouped” data from query

I have a table that looks like this (simplified): CREATE TABLE IF NOT EXISTS records ( user_id uuid NOT NULL ts timestamptz NOT NULL, op_type text NOT NULL, PRIMARY KEY (...
1
vote
2answers
42 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') ...
1
vote
1answer
50 views

How to do a bulk insert with node-postgres

I am importing an excel file into a postgres database with express and node-pg Currently I am looping through the excel rows and executing an insert for every row but I feel it's not the right way: ...
0
votes
4answers
85 views

How to return a result from a generator calling an asynchronous function?

I'm using the Koa framework and ES6. How do I get the first method to return a result to this view function that requires a yield? I am trying to use the pg library, which uses asynchronous calls, in ...
0
votes
1answer
18 views

Am I doing connection pooling correctly? Using node-postgres library

I am reading the documentation and trying to figure out connection pooling. The documentation says that the pool should be long lived, so I have created a config/db.js file where I create pool and ...
1
vote
1answer
48 views

net.Stream is not a constructor - Node Postgres

I'm trying to connect a Node.js app with a PostgreSQL server. It seems that no matter what I use, I end up with the same error: bundle.js:16177 ERROR: TypeError: net.Stream is not a constructor at ...
0
votes
0answers
65 views

Nodejs Postgres Query with Call

I'm trying to use the recommendation of the creator of node-postgres and separate the database call as a separate file. This will enable both scaling and consolidation of the various, boilerplate ...
1
vote
0answers
39 views

node-postgres select outputs query detail in addition to data

I am using a node-postgres 'client.query' to Select from a postgres 9.6/postgis 2.3 db. The Select statement is: SELECT json_build_object('type','FeatureCollection','crs',json_build_object ('type',...
9
votes
2answers
7k 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. ...
0
votes
0answers
24 views

Is it possible to stream blob by node-postgres?

I am curious whether streaming blob is out of the box supported by node-postgres, or do I have to use a lib for that, for example: node-pg-large-object?
0
votes
0answers
69 views

How to set schema in pg-promise

I was searching the documentation of pg-promise specifically in the creation of the client. But I wasn't able to find the option to set the default schema to be used in the connection, it always uses ...
0
votes
0answers
84 views

webpack import error with node-postgres ('pg'.Client)

Trying to bundle the following file with Webpack fails with ERROR in ./~/pg/lib/native/index.js Module not found: Error: Cannot resolve module 'pg-native' in .../node_modules/pg/lib/native @ ...
0
votes
3answers
138 views

Insert POINT into postgres database

I need to insert/update a point column type in postgres database. I'm using node-postgres The script generated using POSTGRES admin panel shows the update query as UPDATE public.places SET id=?, ...
3
votes
2answers
75 views

Does pg (node-postgres) automatically sanitize data

I am using node-postgres for a production application and I am wondering if there is anything I should be concerned about? Is the data sanitized automatically by node-postgres? I couldn't find ...
6
votes
2answers
4k views

node server can't connect to postgres db

I recently switched from MySQL to postgres as my database for an node.js project. While I'm able to reach my remote postgres database from my local pgAdmin III (OSX) client, so far I've been unable to ...
29
votes
5answers
12k 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 ...
1
vote
1answer
94 views

How to end 'pg-promise' app

I am trying to write a REST API which based on the request payload picks a database and performs certain actions. As per the documentation, I am releasing the shared connection object at the end of ...
2
votes
1answer
105 views

node-postgres UTF password bug

I'm using https://github.com/brianc/node-postgres pg module. Apparently I can't consume a Unicode password to connect to the db. From the same location psql with connection parameters goes OK. With ...
0
votes
0answers
34 views

How to manage properly db connection errors outside javascript function?

I have an AWS lambda that look like this : 'use strict'; const config = require('./config'); const pg = require('pg'); exports.handler = function(event, context) { const client = new pg.Client(...
1
vote
1answer
213 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-...
0
votes
1answer
33 views

Decrypting Data From Database Before Sending Response Back Node.js

Update The actual problem I am having is placing the value back inside the response after I decrypt it. I just need to know how to place a value back in the response after I manipulate it. ...
2
votes
5answers
3k 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-...
11
votes
1answer
322 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 ...
0
votes
2answers
51 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
29 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
73 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
137 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. ...
3
votes
3answers
562 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
158 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
59 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
79 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
28 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
69 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
48 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 ...
1
vote
1answer
65 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
232 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( '...
0
votes
0answers
57 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((...
0
votes
1answer
38 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],...
2
votes
0answers
99 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
91 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
107 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. ...
3
votes
1answer
237 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 ...
2
votes
1answer
95 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
32 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
73 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
144 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
5k 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,...