my data structure schema is like
users(
id serial primary key,
data json
);
I want to update data key.
I'm using node-postgres library and So far I have tried something like this:
pg.connect(process.env.DATABASE_URL, function(err, client, done) {
var queryString = "UPDATE users SET data =" + myNewJsonData + " WHERE id = " + userIdToEdit + ";";
client.query(queryString, function(err, result) {
done();
if (err) {
res.send("Failed to update user data ");
throw err;
} else {
res.send("Successfully updated user data!! ");
}
});
});
this is not working, I'm getting error invalid input syntax for type json
Can anyone help, Thanks.
UPDATE, what is wrong with the syntax around the JSON column? And you don't even include whatmyNewJsonDatais.