diff --git a/bindTicketShelving2.js b/bindTicketShelving2.js index 4972335..f1a29bf 100644 --- a/bindTicketShelving2.js +++ b/bindTicketShelving2.js @@ -9,13 +9,14 @@ var collectionFk = '254'; function ticketCollection(collectionFk){//parametro collectionFk - let consultaSql = select.select(collectionFk) - if(filter.filterShelving(shelving)){ - // insert.insertTicket(consultaSql, shelving) - } - else{ - console.log("¡MATRICULA INCORRECTA!") - } + select.select(collectionFk, function(err,data){ + if(filter.filterShelving(shelving)){ + insert.insertTicket(data, shelving) + } + else{ + console.log("¡MATRICULA INCORRECTA!") + } + }); } ticketCollection(collectionFk, shelving); \ No newline at end of file diff --git a/db/selectDB.js b/db/selectDB.js index 3945bfe..5f34e56 100644 --- a/db/selectDB.js +++ b/db/selectDB.js @@ -4,22 +4,17 @@ const con = require('./connect') //cliente //agencia var x; -function select(collectionFk){ - con.con.connect(function(err) { - let consSql = `SELECT t.id, t.clientFk, am.name - FROM ticketCollection tc - JOIN ticket t ON t.id = tc.ticketFk - JOIN agencyMode am ON am.id = t.agencyModeFk - WHERE tc.collectionFk = ${collectionFk}`; - if (err) throw err; - con.con.query(consSql, function (err, result, fields) { - if (err) throw err; - console.log(result); - x = result; - }); - }); - console.log("RESULT FUERA "+x); -} +function select(collectionFk, callback){ + let consSql = `SELECT t.id, t.clientFk, am.name + FROM ticketCollection tc + JOIN ticket t ON t.id = tc.ticketFk + JOIN agencyMode am ON am.id = t.agencyModeFk + WHERE tc.collectionFk = ${collectionFk}`; + con.con.query(consSql, function (err, result, fields) { + console.log(result); + callback(null,result); + }); +} exports.select = select;