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

learn more… | top users | synonyms

0
votes
0answers
43 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 ...
0
votes
3answers
75 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 ...
1
vote
0answers
32 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',...
1
vote
1answer
37 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
19 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
54 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
56 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
71 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
52 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 ...
1
vote
1answer
79 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 ...
0
votes
0answers
32 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(...
0
votes
1answer
29 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. ...
0
votes
2answers
43 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
28 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
41 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
0answers
53 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 ...
5
votes
2answers
136 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
54 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
26 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
53 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
36 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
170 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
62 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
164 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
1answer
113 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. ...
0
votes
0answers
53 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
37 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],...
11
votes
1answer
275 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
93 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 ...
3
votes
1answer
184 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
37 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
82 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
31 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
63 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
124 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....
0
votes
1answer
108 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
27 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
62 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....
1
vote
1answer
106 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 ...
2
votes
1answer
51 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
31 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
127 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: ...
0
votes
3answers
78 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 | ...
-1
votes
1answer
100 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
51 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} },{})...
0
votes
1answer
156 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 ...
1
vote
1answer
77 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
480 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
57 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.
1
vote
2answers
167 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-...