diff --git a/src/libs/routes/idhme.js b/src/libs/routes/idhme.js index cd60b54f26fba3f0b42079a11cc396b9b640d9d6..9791fb0725f440b8a2863d80db24daa9dea11879 100644 --- a/src/libs/routes/idhme.js +++ b/src/libs/routes/idhme.js @@ -45,12 +45,12 @@ rqf.addField({ relation: '=', type: 'integer', field: 'estado_id', - table: 'adh_idh' + table: 'adh_idh_uf' }, join: { primary: 'id', foreign: 'estado_id', - foreignTable: 'adh_idh' + foreignTable: 'adh_idh_uf' } }).addValue({ name: 'year', @@ -73,12 +73,20 @@ idhmeApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { message: 'Wrong/No filter specified' }); } - req.sql.from('adh_idh') + if ("state" in req.filter) { + // console.log("sim"); + req.sql.from('adh_idh_uf') + .field('adh_idh_uf.idhm_e', 'IDHME') + .field('adh_idh_uf.ano_censo', 'year') + .field('adh_idh_uf.estado_id', 'state_id'); + next(); + } else if ("city" in req.filter) { + req.sql.from('adh_idh') .field('adh_idh.idhm_e', 'IDHME') .field('adh_idh.ano_censo', 'year') - .field('adh_idh.estado_id', 'state_id') .field('adh_idh.municipio_id', 'city_id'); - next(); + next(); + } }, query, response('idhme')); module.exports = idhmeApp;