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;`; con.con.query(sql, function(err, result) { console.log(err); }); } exports.insertSmartTag = insertSmartTag;