I am using the MySQL driver for Node.js “node-mysql” but struggling with the syntax to do a REPLACE into and increment a counter. Here’s what I have so far, note the count field is where I want to increment the current table value by 1:
connection.query('REPLACE INTO links SET ?', { symbol: statName, timestamp: now, count: count + 1 }, function(err, result) {
Can anyone advise on how to do this?
I found the solution in using INSERT with ON DUPLICATE KEY UPDATE: