I’m stuck with the issue of sending response back to the caller after retrieving something from Postgres database. It appears that headers are automatically written after fetchUserDB is executed (regardless of its success). This leads to the error ERR_HTTP_HEADERS_SENT when I try to return the response back using res.json() menthod. These are the headers after fetchUsedDB is called (just before
Tag: node-postgres
Node js shared variables and multiple users and multiple entry-points
I have an node-js application that I’m switching from a single-tenant database to a multi-tenant database. The application code is called from an express api but there are also services that run through a different entrypoints, so req.session is not always available. Currently I have database function calls all throughout the app like: database.select.users.findByUserId(123, callback) Since the app is changing
How do I properly insert multiple rows into PG with node-postgres?
A single row can be inserted like this: This approach automatically comments out any special characters. How do i insert multiple rows at once? I need to implement this: I can just use js string operators to compile such rows manually, but then i need to add special characters escape somehow. Answer Following this article: Performance Boost from pg-promise library,