insert in DB

This commit is contained in:
llopis15 2021-03-12 13:54:21 +01:00
parent d83d73ce49
commit 89e3a1b465
3 changed files with 5 additions and 3 deletions

View File

@ -22,7 +22,6 @@ function bindShelving(barcode, shelving, level){
})
console.log(body)
})();
insertDB.insertDB(barcode, shelving, level);
})();
}
exports.bindShelving = bindShelving;

View File

@ -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!")
}

View File

@ -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");
});
});
}
}
exports.insertDB = insertDB;