Postgres: "Error occurred: error: column \"id\" does not exist"

Viewed 192

I have a Node / Express / Postgres application. Postgres is deployed on AWS RDS and I'm using pg in node.

Here's my code:

module.exports.getProductById = async (id) => {
 const result = await pool.query('SELECT * FROM "Products" WHERE id =  $1', [id]);

 return result.rows[0];   
}

I get the following error when I run this function: "Error occurred: error: column "id" does not exist"

id column does exist in the Products database, and it's in lowercase. When I run the query in pgAdmin it runs fine. I tried to specify columns and it returns an error for each column.

For example, if I SELECT price from "Products", I get the error the price doesn't exist. I made sure that all columns are in lowercase.

I created a local copy of the database on my laptop, and it works fine as well. At this point I've exhausted all options, and have probably went over 20 similar articles and can't seem to find what the issue is.

I would really appreciate your help with this.

0 Answers
Related