I'm having the following error:
I have a post form to insert some values to a postgres database using pg-promise. Those values are being converted to integers on the server. But when I try to insert the values to postgres, it says:
invalid input syntax for integer: ""
What I'm trying to do:
Every field that its left blank, convert it to NULL and insert it to the database, here's the code:
var tier_1 = parseInt(req.body.tier_1);
if (isNaN(tier_1)) {
console.log("Not a Number");
tier_1= null;
}
and the query:
"insert into products(tier_1) values (${tier_1})"
but postgres still reads tier_1 as a string.
Any ideas?
Thank you!