Skip to content
Snippets Groups Projects
Commit 9a6bb2b6 authored by Lucas Gabriel Lima's avatar Lucas Gabriel Lima
Browse files

add region to rqf values

parent ebc60ea0
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!58Pib per capita e População
Pipeline #
......@@ -65,6 +65,22 @@ rqf.addField({
foreign: 'estado_id',
foreignTable: 'ibge_populacao'
}
}).addValue({
name: 'region',
table: 'regiao',
tableField: 'nome',
resultField: 'region_name',
where: {
relation: '=',
type: 'integer',
field: 'regiao_id',
table: 'ibge_populacao'
},
join: {
primary: 'id',
foreign: 'regiao_id',
foreignTable: 'ibge_populacao'
}
}).addValue({
name: 'min_year',
table: 'ibge_populacao',
......@@ -98,13 +114,12 @@ populationApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('ibge_populacao.ano_censo')
next();
}, query, (req, res, next) => {
let somapop = 0;
for (var i = 0; i < req.result.length; i++) {
somapop += req.result[i].population;
}
req.result = [{population: somapop, year: req.result[0].year}];
console.log(req.params);
// let somapop = 0;
// for (var i = 0; i < req.result.length; i++) {
// somapop += req.result[i].population;
// }
//
// req.result = [{population: somapop, year: req.result[0].year}];
next()
}, id2str.transform(true), response('population'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment