master #2
|
@ -2,11 +2,11 @@ const mysql = require('mysql');
|
|||
const config = require('../config');
|
||||
|
||||
const con = mysql.createConnection({
|
||||
user: config.db.user,
|
||||
password: config.db.password,
|
||||
host: config.db.host, // 'test-db.verdnatura.es',
|
||||
port: config.db.port,
|
||||
database: config.db.database,
|
||||
user: config.db.user,
|
||||
password: config.db.password,
|
||||
insecureAuth: true
|
||||
});
|
||||
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
const con = require('./connect');
|
||||
|
||||
function insertSmartTag(smartTagFk, shelving, level) {
|
||||
let sql = `IF EXISTS(SELECT * FROM vn.smartTag WHERE code='${smartTagFk}')
|
||||
THEN
|
||||
UPDATE vn.smartTag
|
||||
SET shelvingFk = '${shelving}', level = ${level}
|
||||
WHERE code='${smartTagFk}';
|
||||
ELSE
|
||||
INSERT
|
||||
INTO vn.smartTag (code, shelvingFk, level)
|
||||
VALUES ('${smartTagFk}', '${shelving}', ${level});
|
||||
END IF;`;
|
||||
let sql = `INSERT INTO vn.smartTag (code, shelvingFk, level)
|
||||
VALUES ('${smartTagFk}', '${shelving}', ${level})
|
||||
ON DUPLICATE KEY
|
||||
UPDATE shelvingFk = '${shelving}', level = ${level};`;
|
||||
con.con.query(sql, function(err, result) {
|
||||
console.log(err);
|
||||
if (err)
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
exports.insertSmartTag = insertSmartTag;
|
||||
|
|
Reference in New Issue