I am using node-mysql
to update the MySQL database table from node.js. I want to update the timestamp column of a row using CURRENT_TIMESTAMP
. However, no changes are apparently made using node.js using the following code:
Node.js Code
client.query('UPDATE listings SET job_checkout_timestamp = CURRENT_TIMESTAMP WHERE listing_id = 1515');
But it works if I replace CURRENT_TIMESTAMP
with a javascript time function like new Date()
client.query('UPDATE listings SET job_checkout_timestamp = ? WHERE listing_id = 1515', [ new Date() ]);
However, if I were to execute the same SQL query directly in mysql (using Navicat), the row is updated with the current timestamp!
Direct SQL query
UPDATE listings SET job_checkout_timestamp = CURRENT_TIMESTAMP WHERE listing_id = 1515;
Something went wrong?
source share