diff --git a/bindShelving.js b/bindShelving.js index 44f11bb..197bdcf 100644 --- a/bindShelving.js +++ b/bindShelving.js @@ -22,7 +22,6 @@ function bindShelving(barcode, shelving, level){ }) console.log(body) })(); - insertDB.insertDB(barcode, shelving, level); })(); } exports.bindShelving = bindShelving; \ No newline at end of file diff --git a/bindShelvingTag.js b/bindShelvingTag.js index dcac66b..c08839e 100644 --- a/bindShelvingTag.js +++ b/bindShelvingTag.js @@ -1,12 +1,14 @@ const insertShelving = require('./insertShelving'); const bindShelving = require('./bindShelving'); const filter = require('./filter'); +const insertDB = require('./db/insertDB') function bindShelvingTag(barcode, shelving, level){ if(filter.filterBarcode(barcode)){ if(filter.filterShelving(shelving)){ insertShelving.insertShelving(shelving, level); bindShelving.bindShelving(barcode, shelving, level); + insertDB.insertDB(barcode, shelving, level); }else{ console.log("¡MATRICULA INCORRECTA!") } diff --git a/db/insertDB.js b/db/insertDB.js index 42525aa..bcfa053 100644 --- a/db/insertDB.js +++ b/db/insertDB.js @@ -4,10 +4,11 @@ function insertDB(barcode, shelving, level){ con.con.connect(function(err) { if (err) throw err; console.log("Connected!"); - var sql = `INSERT INTO vn.smartTag (code, shelvingFk, level) VALUES (${barcode}, ${shelving}, ${level})`; + var sql = `INSERT INTO vn.smartTag (code, shelvingFk, level) VALUES ('${barcode}', '${shelving}', ${level})`; con.con.query(sql, function (err, result) { if (err) throw err; console.log("1 record inserted"); }); }); -} \ No newline at end of file +} +exports.insertDB = insertDB; \ No newline at end of file