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({ ...@@ -21,11 +21,11 @@ rqf.addField({
}).addValue({ }).addValue({
name: 'id', name: 'id',
table: 'escola', table: 'escola',
tableField: 'cod_entidade', tableField: 'id',
where: { where: {
relation: '=', relation: '=',
type: 'integer', type: 'integer',
field: 'cod_entidade' field: 'id'
} }
}).addValue({ }).addValue({
name: 'city', name: 'city',
...@@ -35,12 +35,12 @@ rqf.addField({ ...@@ -35,12 +35,12 @@ rqf.addField({
where: { where: {
relation: '=', relation: '=',
type: 'integer', type: 'integer',
field: 'fk_municipio_id', field: 'municipio_id',
table: 'escola' table: 'escola'
}, },
join: { join: {
primary: 'pk_cod_ibge', primary: 'id',
foreign: 'fk_municipio_id', foreign: 'municipio_id',
foreignTable: 'escola' foreignTable: 'escola'
} }
}).addValue({ }).addValue({
...@@ -51,14 +51,25 @@ rqf.addField({ ...@@ -51,14 +51,25 @@ rqf.addField({
where: { where: {
relation: '=', relation: '=',
type: 'integer', type: 'integer',
field: 'fk_estado_id', field: 'estado_id',
table: 'escola' table: 'escola'
}, },
join: { join: {
primary: 'pk_estado_id', primary: 'id',
foreign: 'fk_estado_id', foreign: 'estado_id',
foreignTable: 'escola' 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) => { schoolApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
...@@ -71,10 +82,10 @@ 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') req.sql.from('escola')
.field('escola.cod_entidade', 'id') .field('escola.id')
.field('escola.ano_censo', 'year') .field('escola.ano_censo', 'year')
.field('escola.fk_estado_id', 'state_id') .field('escola.estado_id', 'state_id')
.field('escola.fk_municipio_id', 'city_id'); .field('escola.municipio_id', 'city_id');
next(); next();
}, query, response('school')); }, 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