Questions tagged [node-postgres]

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

About

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

Its source code and wiki can be found on GitHub.

450 questions
0
votes
1 answer

Node-postgres parameterized query for INSERT INTO if not exists

I have a working parameterized query for an insert statement but I now want to add in a 'WHERE NOT EXISTS' clause. The working insert looks like this: pgClient.query("INSERT INTO social_posts (username, user_image, message, image_url, post_id,…
dshamis317
  • 81
  • 1
  • 11
0
votes
1 answer

Convert rows to lowercase in node-postgres

I'm currently using node-postgres to query my DB like so: SELECT DISTINCT(name) FROM users.names ORDER BY name; I want to return the lowercase of these names, so I've tried this: SELECT DISTINCT(lower(name)) FROM users.names ORDER BY…
MattDionis
  • 3,194
  • 6
  • 43
  • 93
0
votes
1 answer

Query unknown number of keywords in Postgres

I'm currently using postgres in node to query all users who have a certain tag associated with their account like so (note: I'm using node-postgres): query = 'SELECT tags.*, pl.email FROM admin.tags tags LEFT JOIN gameday.player_settings pl ON…
MattDionis
  • 3,194
  • 6
  • 43
  • 93
0
votes
1 answer

Unable to fathom node-postgres error

Using node-postgres, the following snippet works fine: let shift_solutions = function (ufrom, uto) { let cmd = 'update solutions set "user" = \''+uto+'\' where "user" = \''+ufrom+'\'' client.query( cmd, null, function (err,rslt) { …
stephensong
  • 247
  • 1
  • 12
0
votes
1 answer

Is "raise exception" the only way to return an error from pgplsql to node-postgres?

Say, I have a pgplsql function (e.g. buyItem) which returns something (e.g. bought item parameters). In some cases I want to indicate that something went wrong so the result is empty (e.g. not enough money to buy desired item). It's just a usual…
Denis Zhbankov
  • 638
  • 1
  • 8
  • 10
0
votes
1 answer

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 how to reference that property. { [error: function…
Jonathan
  • 62
  • 1
  • 9
0
votes
1 answer

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, function(err, client, done){ if (err) { done(); return…
JivanAmara
  • 975
  • 1
  • 9
  • 20
0
votes
1 answer

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 done(client) removes the connection from the pool. My…
0
votes
1 answer

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, next){ ^ TypeError: Cannot call method 'use'…
Trevor Panhorst
  • 259
  • 3
  • 17
0
votes
1 answer

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 variables, but I'd rather pass them around as an…
user1164937
  • 1,509
  • 2
  • 15
  • 27
0
votes
0 answers

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); Query: getter.query('SELECT EXISTS (SELECT 1 FROM users…
Kinnard Hockenhull
  • 2,112
  • 5
  • 23
  • 32
0
votes
3 answers

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 the same database connection. The function…
maxluzuriaga
  • 1,267
  • 8
  • 16
0
votes
1 answer

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 mongodb class for node.js, and I was really fascinated…
user1164937
  • 1,509
  • 2
  • 15
  • 27
0
votes
1 answer

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 contains a require('pg') it specifically states…
ins0m
  • 840
  • 10
  • 19
0
votes
4 answers

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 client.query(query, callback) call I am inside a…
luigi7up
  • 4,783
  • 2
  • 40
  • 52
1 2 3
29
30