2

Im trying to update multiple columns in the same table. Im using node-postgres Here is what my code looks like.

client.query('UPDATE mytable SET column1 = ($1), column2 = ($2) WHERE id = ($3)',[data.a,data.b,data.id]);

The code goes through with no errors however the columns don't get updated. The data (data.a,data.b,data.id) is defined properly.

Am I missing something vital?

2
  • Please try the same thing with literal values in the query. This should give you a hind. Commented Dec 1, 2017 at 10:03
  • do you commit? or at least end session?.. Commented Dec 1, 2017 at 10:22

1 Answer 1

1

Thank you to all who helped.

All through the data was defined properly it was not actually being transferred on POST. Specifically data.id so the node-pg would not give an error but would not go through either since the data.id is missing.

After putting data.id within my form group it was solved.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.