Skip to content
Snippets Groups Projects
Commit 3065cae1 authored by Gabriel Ruschel's avatar Gabriel Ruschel
Browse files

Right result query

parent 20a3da26
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!91Siope route
Pipeline #
...@@ -46,7 +46,7 @@ siopeApp.get('/years', (req, res, next) => { ...@@ -46,7 +46,7 @@ siopeApp.get('/years', (req, res, next) => {
rqf.addField({ rqf.addField({
name: 'filter', name: 'filter',
field: false, field: true,
where: true where: true
}).addField({ }).addField({
name: 'dims', name: 'dims',
...@@ -71,8 +71,8 @@ rqf.addField({ ...@@ -71,8 +71,8 @@ rqf.addField({
}).addValue({ }).addValue({
name: 'state', name: 'state',
table: 'estado', table: 'estado',
tableField: 'nome', tableField: ['id','nome','sigla'],
resultField: 'state_name', resultField: ['state_id','state_name','state_abbreviation'],
where: { where: {
relation: '=', relation: '=',
type: 'integer', type: 'integer',
...@@ -149,15 +149,14 @@ siopeApp.get('/', rqf.parse(), (req, res, next) => { ...@@ -149,15 +149,14 @@ siopeApp.get('/', rqf.parse(), (req, res, next) => {
next(); next();
}, rqf.multibuild(), multiQuery, (req, res, next) => { }, rqf.multibuild(), multiQuery, (req, res, next) => {
let result = {} let result = []
if ('state' in req.filter) {
req.result[req.queryIndex.siopeUf].forEach((item) => { req.result[req.queryIndex.siopeUf].forEach((item) => {
let keys = Object.keys(item); result.push(item)
keys.forEach((key) => { });
result[key] = item[key]; req.result[req.queryIndex.siopeMun].forEach((item) => {
}); result.push(item)
}); });
}
req.result = result; req.result = result;
next(); next();
......
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