Skip to content
Snippets Groups Projects
Commit 029f378b authored by João Victor Risso's avatar João Victor Risso
Browse files

Fix city query by IBGE code route

parent a7f9345b
No related branches found
No related tags found
1 merge request!7Refactor enrollments route to include query building
Pipeline #
...@@ -52,9 +52,9 @@ cityApp.get('/:id', function (req, res) { ...@@ -52,9 +52,9 @@ cityApp.get('/:id', function (req, res) {
cityApp.get('/ibge/:id', function (req, res) { cityApp.get('/ibge/:id', function (req, res) {
var citySql = 'SELECT * FROM municipios WHERE codigo_ibge = ?'; var citySql = 'SELECT * FROM municipios WHERE codigo_ibge = ?';
var cityId = parseInt(req.params.id, 10); var cityIbgeCode = req.params.id;
conn.prepare(citySql, true).then(function (dbQuery) { conn.prepare(citySql, true).then(function (dbQuery) {
dbQuery.exec([cityId]).then(function (dbResult) { dbQuery.exec([cityIbgeCode]).then(function (dbResult) {
log.debug(dbResult); log.debug(dbResult);
req.result = dbResult; req.result = dbResult;
response(req, res); response(req, res);
......
...@@ -56,9 +56,9 @@ cityApp.get('/:id', (req, res) => { ...@@ -56,9 +56,9 @@ cityApp.get('/:id', (req, res) => {
cityApp.get('/ibge/:id', (req, res) => { cityApp.get('/ibge/:id', (req, res) => {
const citySql = 'SELECT * FROM municipios WHERE codigo_ibge = ?'; const citySql = 'SELECT * FROM municipios WHERE codigo_ibge = ?';
const cityId = parseInt(req.params.id, 10); const cityIbgeCode = req.params.id;
conn.prepare(citySql, true).then((dbQuery) => { conn.prepare(citySql, true).then((dbQuery) => {
dbQuery.exec([cityId]).then( dbQuery.exec([cityIbgeCode]).then(
(dbResult) => { (dbResult) => {
log.debug(dbResult); log.debug(dbResult);
req.result = dbResult; req.result = dbResult;
......
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