maxWagons repared

This commit is contained in:
llopis15 2021-03-24 11:45:57 +01:00
parent 768b5c220c
commit af88f176b7
2 changed files with 8 additions and 13 deletions

View File

@ -1,7 +1,7 @@
const con = require('./connect');
function maxWagon(collectionFk, callback) {
let consSql = `SELECT MAX(tc.wagon)
let consSql = `SELECT MAX(tc.wagon) AS MaxWagons
FROM ticketCollection tc
WHERE tc.collectionFk = ${collectionFk}`;
con.con.query(consSql, function(err, result, fields) {

View File

@ -1,24 +1,19 @@
const express = require('express');
const router = express.Router(); // eslint-disable-line
const select = require('../db/selectDB');
const maxWagon = require('../db/maxWagon');
router.get('/:collectionFk', async(req, res) => {
const maxWagon = require('../db/maxWagon');
// var collectionFk = '273449';
const collectionFk = req.params.collectionFk;
let maxWagon = ticketCollection(collectionFk);
res.json({
message: 'SUCCESS',
maxWagon: maxWagon
maxWagon.maxWagon(collectionFk, function(err, max) {
let maxWagons = max[0].MaxWagons;
res.json({
message: 'SUCCESS',
maxWagons: maxWagons
});
});
});
module.exports = router;
function ticketCollection(collectionFk) {// parametro collectionFk
select.select(collectionFk, function(err, data) {
maxWagon.maxWagon(collectionFk, function(err, max) {
return max;
});
});
}