fore.st/src/util/on-duplicate-key-update.js
2021-12-06 19:56:40 -05:00

7 lines
236 B
JavaScript

export function createMySQLDuplicateKeyUpdate(columns) {
const prefix = ' on duplicate key update ';
const updates = columns.map(col => `\`${col}\` = values(\`${col}\`)`)
.join(', ');
return prefix + updates;
}