I’ve built an Express.js app, hosted by Heroku, with a non-embedded PostgreSQL database. The app was running as intended until about a month ago, and for several months before that. However, when I logged in today, I ran into a serious problem. Whenever I try to access any page which queries the database, it tries to load for a few
Tag: postgresql
Encountering a problem when trying to insert JSON data into my postgres database – Node.js
I’m having a problem when i try to save my JSON data into a database. Right now, i have this code here: My service that retrieves and cache data from an API with the given parameter cep: My route using the service: It works with out problems: Here that comes the problem. When i try to insert the data into
Using placeholders with copy and pg-query-stream
I’m trying to extract a query as a csv file. I tried to use copy with pg-query-stream to execute the query but I’m facing this error: error: bind message supplies 1 parameters, but prepared statement “” requires 0 when removing copy from the query it works fine with the placeholders also if I provided a query with copy and no
TypeORM fails to connect without any error message
I am trying to get started with TypeORM, but cannot get createConnection to work. I run the default tpyeorm init server file, but there is not error or logging shown, nor is the postgres DB updated. index.ts ormconfig.json (note: I changed the postgres password to ‘root’) running start gives the following output: Note that none of the other logging statements
How to update a constraint in a migration
I need to add onDelete and onUpdate cascade to a constraint in a migration file. So i did an alter table, selecting the foreign keys and chaining with the alter method in the end of each command. But i’m getting a error saying that the constraint of this relationship already exists. error: constraint “deliveries_courier_id_foreign” for relation “deliveries” already exists How
Sequelize returns null for Postgres ‘timestamp with time zone’ columns
I’m new to Sequelize and am having trouble getting timestamp data from a Postgres database. Everything I have tried so far returns null for all timestamp fields. Below are the Postgres definitions for the columns in question: These are all the different ways I’ve attempted to define the relevant portion of the model in Node.js (tried the same things for
Compare Timestamp with date in sequelize query
I have createdAt column which stores value as “2018-11-07 15:03:16.532+00”. I want to write query like select * from table_name where createdAt = input_date, where myinput_date is only date value like 2018-11-07. How do i write this query using Sequelize? Answer try using the sequelize.fn() argument, for example like this, try adjusting it. Ex:
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,
What is this JavaScript “require”?
I’m trying to get JavaScript to read/write to a PostgreSQL database. I found this project on GitHub. I was able to get the following sample code to run in Node. Next I tried to make it run on a webpage, but nothing seemed to happen. I checked on the JavaScript console and it just says “require not defined”. So what