From 89e3a1b4651f5ae37db091c501706eea5fde603c Mon Sep 17 00:00:00 2001 From: llopis15 Date: Fri, 12 Mar 2021 13:54:21 +0100 Subject: [PATCH] insert in DB --- bindShelving.js | 1 - bindShelvingTag.js | 2 ++ db/insertDB.js | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) 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