further changes, migrate to mysql2

This commit is contained in:
Dave Horton
2019-12-16 16:32:40 -05:00
parent ca07702e49
commit 7c2e12a4be
7 changed files with 167 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
const mysql = require('mysql');
const mysql = require('mysql2');
const config = require('config');
const pool = mysql.createPool(config.get('mysql'));

View File

@@ -9,7 +9,7 @@ function sysError(logger, res, err) {
logger.info(err, 'unprocessable request');
return res.status(422).json({msg: err.message});
}
if (err.message.includes('ER_DUP_ENTRY')) {
if (err.code === 'ER_DUP_ENTRY') {
logger.info(err, 'duplicate entry on insert');
return res.status(422).json({msg: err.message});
}