Questions tagged [pg-promise]

Complete access layer to node-postgres via Promises/A+.

Built on top of node-postgres and its connection pool, this library translates their callback interface into one based on Promises/A+, while extending the protocol to a higher level, with automated connections and transactions management.

In addition, the library provides:

  • its own, more flexible query formatting;
  • event reporting for connectivity, errors, queries and transactions;
  • declarative approach to controlling query results;
  • support for all popular promise libraries.
521 questions
0
votes
1 answer

Set results to be array in a new column for over a million rows -postgreSQL

I am trying to get all the photo urls into an array and set that array to be a new column in a different table. The tables have a one to many relationship. I have about 1 million rows on my list_reviews table and around 3 million photos. Is there…
TomC
  • 5
  • 4
0
votes
1 answer

nodejs, pg-promise : Best Repository Pattern

I have some troubles to chose my repository pattern for my API. The database is composed of several tables that can be grouped in two "parts". Have I to do one repository for each table (first example) or only one for each "parts" (second example)…
Firlfire
  • 413
  • 1
  • 6
  • 14
0
votes
1 answer

How to execute a batch of transactions independently using pg-promise?

We're having an issue in our main data synchronization back-end function. Our client's mobile device is pushing changes daily, however last week they warned us some changes weren't updated in the main web app. After some investigation in the logs,…
greenkarmic
  • 429
  • 4
  • 17
0
votes
1 answer

first transaction blocking DB (SAVEPOINT and connection lost)

I can shorten my post if necessary I use a pg-promise transaction to insert a 'device' and all of its part (like system, disk, ...). The transaction works... but only the first time. After it my server can no more interact with the DB (neither…
Firlfire
  • 413
  • 1
  • 6
  • 14
0
votes
1 answer

(async) JSON RPC API performance optimization

I have to make a JSON RPC API that will have to support a big traffic and manage a postgreSQL database. To do it I chose 'http' for the server and pg-promise for the database. My problem is that I have some difficulty understanding and using the…
Firlfire
  • 413
  • 1
  • 6
  • 14
0
votes
0 answers

Why am I malformed literal error with pg-promise when SELECT has WHERE condition on a numrange?

I am trying to select an item from a table where a given number fit's into its cost range. It seems to work if I manually set $/cost/ to a 3.136 but as soon as I try to use a named parameter it fails. I am using other variables int he full query…
Matt Weber
  • 2,808
  • 2
  • 14
  • 30
0
votes
1 answer

Is pg-promise supports multiple host addresses(primary and secondary) in connection string?

As per postgresql documentation, we can use the multiple hosts(primary and secondary) in connection string.We are using pg-promise node driver to run postgresql queries.As far i know pg-promise doesn't supporting multiple hosts.If anyone used this…
sachin
  • 35
  • 1
  • 5
0
votes
0 answers

Formatting/escaping jsonb attribute names

Given a table with jsonb field and a list of attribute names. How do I go about formatting a query to select all the attributes in the list? I have a list with attribute name: Never say 'Never' create table t(a jsonb); insert into t values('{…
0
votes
1 answer

Relation doesnt exist Multi-row insert with pg-promise

I'm developing a nodejs project with a postgresql-db. I've created a table called 'UserAsanas'. It's definitely there, I've checked and re-checked. But when I try to multi-row insert it keeps telling me the following: error: relation "UserAsanas"…
ClaraG
  • 322
  • 2
  • 14
0
votes
0 answers

Dynamically setting the schema in pg-promise still warns about duplicate database objects

I have a database that has several different schemas, like a multi-tenant architecture, in Postgres 9.5.7. I've followed the example in this answer to dynamically set the schema for particular queries. All of the context is encapsulated in a class…
BrDaHa
  • 5,138
  • 5
  • 32
  • 47
0
votes
1 answer

How to update redux store with queried data from an express back-end using pg-promises

The developer for a project I'm working on left with only partially completing the front-end and back-end and now I'm trying to connect the Node/Express back-end to the React/Redux front-end in time for the project deadline. The app has a series of…
noe.s
  • 13
  • 1
  • 4
0
votes
1 answer

Multi insert inside a QueryFile

I'm able to generate query for multi inserts or update thanks to pg-promise helpers but I was wondering if I could follow the advice of the author and put all queries outside of my javascript code (See here…
Ghislain
  • 115
  • 1
  • 5
0
votes
0 answers

Insert after another insert in transaction with pg-promise

Ok, I have looked but didn't find anything that worked for me. If you can point me to anything or help my find the solution it would be great. Let's say I have a "users" table (columns: id, username and name) and a "users_items" table (columns:…
dquijada
  • 1,697
  • 3
  • 14
  • 19
0
votes
1 answer

syntax error at or near $1 value pg-promise node.js

i have this code this.createtablePy = function(){ db.none("CREATE TABLE IF NOT EXISTS $1 ( $2 serial NOT NULL, data jsonb", ["pyTable", "id_py"]) .then(()=> { console.log("done pyme table "); }) .catch(error =>{ console.log("Error; "…
onerom
  • 21
  • 5
0
votes
1 answer

How to call pg-promise helpers.insert function?

What is the best way to provide 'pgp' to the following function? Considering 'db' can be db connection, transaction (tx), or task from the above. module.exports = async (db, tableName, records) => { const record_ = records[0] const columns_ =…
Le Ma
  • 3
  • 5