I am trying to do a PostGRESQL update with Node.js, and I get the following error : source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression
I have been using the same principle for create, read, delete, and I had no issues.
What can be wrong ?
Here is my code :
var pg = require("pg")
var pgClient = new pg.Client({
host: 'localhost',
database: 'tutorial',
user: 'postgres',
password: 'password',
port: 5432,
})
pgClient.connect(err => {
if (err) {
console.log('Could not connect to postgres:', err)
process.exit()
}
console.log("Connected to postgres");
});
var aParams = ["Jenny", 1]
var sQuery = 'UPDATE public.users SET (name) = ($1) WHERE (id) = ($2)';
pgClient.query(sQuery, aParams, (err, res) => {
if (err) {
console.log(err)
process.exit()
}
console.log(res.rows)
})