Skip to content
Snippets Groups Projects
Commit ffe4b7c0 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Change school route to new db schema

parent 82785713
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!34Db simcaq dev2
......@@ -21,11 +21,11 @@ rqf.addField({
}).addValue({
name: 'id',
table: 'escola',
tableField: 'cod_entidade',
tableField: 'id',
where: {
relation: '=',
type: 'integer',
field: 'cod_entidade'
field: 'id'
}
}).addValue({
name: 'city',
......@@ -35,12 +35,12 @@ rqf.addField({
where: {
relation: '=',
type: 'integer',
field: 'fk_municipio_id',
field: 'municipio_id',
table: 'escola'
},
join: {
primary: 'pk_cod_ibge',
foreign: 'fk_municipio_id',
primary: 'id',
foreign: 'municipio_id',
foreignTable: 'escola'
}
}).addValue({
......@@ -51,14 +51,25 @@ rqf.addField({
where: {
relation: '=',
type: 'integer',
field: 'fk_estado_id',
field: 'estado_id',
table: 'escola'
},
join: {
primary: 'pk_estado_id',
foreign: 'fk_estado_id',
primary: 'id',
foreign: 'estado_id',
foreignTable: 'escola'
}
}).addValue({
name: 'year',
table: 'escola',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '=',
type: 'integer',
field: 'ano_censo',
table: 'escola'
}
});
schoolApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
......@@ -71,10 +82,10 @@ schoolApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
});
}
req.sql.from('escola')
.field('escola.cod_entidade', 'id')
.field('escola.id')
.field('escola.ano_censo', 'year')
.field('escola.fk_estado_id', 'state_id')
.field('escola.fk_municipio_id', 'city_id');
.field('escola.estado_id', 'state_id')
.field('escola.municipio_id', 'city_id');
next();
}, query, response('school'));
......
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