maxWagons repared
This commit is contained in:
parent
768b5c220c
commit
af88f176b7
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Reference in New Issue