Node-postgres is a postgresql client module for node.js applications to interact with postgresql databases.
1
vote
0answers
7 views
postgres composite type on node-pg
Say I have the following postgreSQL composite type:
CREATE TYPE myType AS(
id bigint,
name text,
);
and a stored procedure that excepts that type:
CREATE FUNCTION myFunction(mt myType){
//do ...
1
vote
2answers
51 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
11 views
First 'property' of node-postgres error object
Anybody know what the first pseudo-property is in my error object on a faulty query? When I console.log('' + error); it grabs the text within the brackets to display. Other than that, I'm not sure ...
0
votes
0answers
3 views
Is done() required if node-postgres .connect() returns with an error?
From the docs it sounds like err is not null if there was a problem getting a client from the pool. If that's the case, does it mean done() doesn't need to be called?
pg.connect(connString, ...
3
votes
0answers
57 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 ...
0
votes
0answers
14 views
node-postgres difference between done() and done(client)
Using node postgres what's the difference between done() and done(client).
According to the docs, if you are using a pool, done() just returns the connection to the pool for future reuse, and ...
0
votes
1answer
24 views
Postgres date using COPY from stream with node-postgres
I have the following table in PostgreSQL:
CREATE TABLE history (
request_date timestamp without time zone DEFAULT now() NOT NULL,
user_id uuid,
client_id character varying(255),
...
1
vote
2answers
58 views
How can I update multiple items from a select query in Postgres?
I'm using node.js, node-postgres and Postgres to put together a script to process quite a lot of data from a table. I'm using the cluster module as well, so I'm not stuck with a single thread.
I ...
0
votes
1answer
107 views
Returning nested JSON from many to many joined table from PostgreSQL to node.js
can anyone help me with querying many to many relation tables in postgres?
i have tables:
> 1.exercise(id,name)
> 2.tag(id,label)
> 3.tag_in_exercise(id,exercise_id,tag_id)
let say, that ...
2
votes
2answers
2k views
How to set right date format for editable-date
I getting some date fileds from postgres with format like:
"2000-11-30T14:00:00.000Z"
I can't use this in my editable-date field on page. Something like:
<a href="#" ...
1
vote
1answer
216 views
Why does this bluebird pg code hang?
I'm trying to wrap my head around bluebird Promises, and going through some examples in the documentation. My current code is based on this example:
var Promise = require('bluebird');
var pg = ...
0
votes
0answers
18 views
node-postgres create enum type
I want to create enum type but it shows me error
[error: syntax error at or near "$1"]
client.query('CREATE TYPE typ AS ENUM ($1)',['ninei'],
function(error, results, fields) {
...
0
votes
0answers
79 views
node-postgres - parse results as GeoJson
Hey so I'm trying to run a query against a postgres database using the fantastic node-postgres module - https://github.com/brianc/node-postgres - however my problem is that I want to return my results ...
0
votes
0answers
53 views
SOLVED Type coercion does not work in Node.js postgresql. Any workarounds?
I'm running against a problem running this query in Node using node-postgres. It runs perfectly in psql. Here it is:
insert into list_items (dataitems_id, idx, lists_id) select li.dataitems_id, ...
0
votes
0answers
217 views
node-postgres prepared statement - sql injection
I am new to node-postgres and am unable to resolve this error when I try to ensure no sql injection is possible with my prepared statement.
Here is a snippet of the code
// the prepared statement
...
0
votes
1answer
199 views
ExpressJS 4.0 exporting routes, getting TypeError
Any suggestions to solve the following error based on the code presented below would be would be appreciated, as I'm simply lost here:
~/public_html/server/routes/api.js:10
api.use(function(req, res, ...
1
vote
0answers
108 views
Memory problems using node_postgres connection pool
im fairly new to node.js and using node_postgres libray. I've been using sockjs and Primus
as transport for my web server prototype. I used PM2 as my monitoring tool on my server and noticed that the ...
0
votes
1answer
264 views
In NodeJS how to save JSON object as text with node-postgres module?
Finally i move forward from postgresql 9.1 to postresql 9.3 that supports JSON data type. Then the same code function properly.
However i think that what i want to do in the first place can be ...
0
votes
0answers
16 views
Creating a database fails with node-postgres
Here's my code, it's pretty much straight out of the docs:
var pg = require('pg');
var client = new pg.Client('postgres://localhost');
client.connect();
var dbName ='myDb';
var query = ...
2
votes
1answer
346 views
Error installing node-postgres on Amazon Linux. Missing pg_config.h file
This error seems common on windows boxes, but my Amazon Linux EC2 instance is throwing this error when I npm install pg:
../src/binding.cc:1:23: fatal error: pg_config.h: No such file or directory
...
0
votes
1answer
97 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 ...
2
votes
2answers
752 views
Manually promisifying pg.connect with Bluebird
I want to promisify node-postgres' pg.connect method along with the inner connection.query method provided in the callback.
I can .promisify the latter, but I need to implement the first one manually ...
0
votes
1answer
43 views
Is it possible to get the SQL statement together with the error returned by node-postgres?
I get errors that look like this from node-postgres (when calling its client.query method):
{ [Error: syntax error at or near "as"]
severity: 'ERROR',
code: '42601',
position: '60',
file: ...
2
votes
1answer
134 views
Retrieving multiple rows with Sequelizejs
I am beginning to learn SequelizeJs however I encounter a small issue:
I have a model which is defined as such:
var ex_table= sequelize.define("ex_table", {
concept1: Sequelize.STRING(5),
...
0
votes
1answer
101 views
krakenjs and node postgres
How do I set up node-postgres using krakenjs? I want to take advantage of node-postgres's connection pooling which requires the client and done parameters. I guess I could set them using global ...
0
votes
0answers
84 views
Parameterized queries with postGIS?
I am trying to use parameterized queries (node-postgres) with postGIS. The error message returned by the query reads "error: bind message supplies 2 parameters, but prepared statement "" requires 0" ...
1
vote
2answers
1k views
Import sql file in node.js and execute against PostgreSQL
I'm looking for an efficient way to take a raw sql file and have it executed synchronously against a postgres database, akin to if you ran it through psql.
I have an sql file which creates all ...
5
votes
1answer
749 views
SSL for PostgreSQL connection nodejs
I am trying to connect to my Heroku PostgreSQL DB and I keep getting an SSL error. Does anyone have an idea on how to enable SSL in the connection string?
postgres://user:pass@host:port/database;
...
1
vote
2answers
1k 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 ...
1
vote
1answer
2k views
can not install node-postgres [closed]
I'm trying to setup node-postgres for my project. However I keep getting these gyp errors when I try to install it. How can I get node-postgres to recognize that my pg_config is located in ...
0
votes
0answers
71 views
Execute Statement using one value of query array
I am attempting to execute a query using a prepared array. The array has two elements but this query uses only one of them. I am using node-postgres.
Array:
var g=[];
g.push(email,password);
...
1
vote
1answer
171 views
NPM alias node-postgres to node-postgres-pure
I'm building a nodejs application that needs to run on a Windows server. I've managed to get almost everything working, but I've ran into a problem with the postgresql driver. BrianC has a pure ...
2
votes
2answers
4k views
Node.js / Express - How to get variables defined in app.js in routes/index.js?
I'm new to Node.js and Express.
How can I access the variable created in "app.js" called "pg" in "routes/index.js"?
app.js
/**
* Module dependencies.
*/
var express = require('express');
var ...
3
votes
2answers
1k 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 ...
1
vote
2answers
196 views
Async pg-node query execution on object's array
I have an object's array which I need to iterate through, and insert each item into the DB (postgres). I'm using _.each in order to iterate through the array.
arr = [
{name: 'Aaron', ...
1
vote
1answer
216 views
Passing array of custom type to postgres function from node-pg and SQL injection
CREATE TYPE phototable AS (
photoid integer,
parentid integer,
fileextension character varying(20),
description text,
tag character varying(100)
);
CREATE FUNCTION addphotos(
...
1
vote
1answer
961 views
Node-postgres date not saving accurately
I'm using Node.js, Postgres, and the node-postgres library. When I try to insert a new record with the current date with code like this:
client.query('INSERT INTO ideas(date) VALUES($1)', [new ...
0
votes
3answers
537 views
Asynchronous Database Queries with PostgreSQL in Node not working
Using Node.js and the node-postgres module to communicate with a database, I'm attempting to write a function that accepts an array of queries and callbacks and executes them all asynchronously using ...
4
votes
2answers
1k views
Error Relation does not exist
I am getting a [error: relation "causes" does not exist] error from my node app. The relation does exist, I'm not sure what the problem is.
I created the table with
CREATE TABLE causes (
cause_id ...
0
votes
1answer
1k views
Express.js structure for node-postgres (pg) and mongodb
First off, I'm fairly new in terms of knowing the performance cost of making a database connection from the server, so excuse me if I say something I may not have meant.
I'm currently taking a ...
0
votes
1answer
676 views
PostgreSQL connection via javascript
I am searching for a way to connect to postgresql directly in the browser. Im trying to utilize nodejs and browserify but have had no luck so far with the bundling. Whenever I compile a script that ...
1
vote
1answer
232 views
error: there is no parameter $1
I get "error: there is no parameter $1" when I try to run this code using the node-postgres client:
app.post('/newcause', function (req,res){
console.log(req.body);
var g;
var r = [];
for ...
1
vote
1answer
271 views
Node-Postgres query method not calling its callback function
I have the following code which uses node-postgres:
var client = new pg.Client(conString);
client.connect(function(err) {
if(err) {
throw new Error(console.error('could ...
1
vote
1answer
609 views
Unable to install the node-postgres node.js module
Please, observe:
c:\Work\if\server>npm install pg
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No README data
npm http GET ...
1
vote
1answer
5k views
node.js, pg, postgresql and insert queries (app hangs)
I have the following simple node application for data insertion into postgres database:
var pg = require('pg');
var dbUrl = 'tcp://user:psw@localhost:5432/test-db';
pg.connect(dbUrl, function(err, ...
0
votes
4answers
612 views
Query callback with arguments and synchronous queries
I have two problems implementing a RESTful service using Node.js / node-postgres lib / PostgreDB and both are due to the async nature of JS.
A) I need to pass an extra argument to a callback in ...
1
vote
0answers
70 views
Can't access postgres database, query doesn't seem to work
var client = new pg.Client(clientConfig);
var queryConfig = {text: 'SELECT messageID FROM privateMessages WHERE message = $1',
values: ['test']};
var server = ...
0
votes
0answers
535 views
Postgresql query problems for nodejs
I am making an app with node.js, using the express framwork, woth postgresql as my database.
I have to insert some values into my database, and some of them have quotes. e.g. Tony's Seafood ...
2
votes
0answers
129 views
pg doesn't seem to close the connection correctly
I am writing an application using Node.js and postgresql. When a user authenticates it hits the DB to check the user's password then supposedly closes the connection to the DB. However, if the user ...
1
vote
2answers
617 views
Return a value from an event emitter callback
I am using the postgresql module 'pg' in node. I would like to do some processing when a row is returned from the database, but I do not know how to return the value to the calling function.
var ...