Fix GET building by toid/uprn
This commit is contained in:
parent
f460aaeef6
commit
1b3fe36e05
@ -40,7 +40,13 @@ function queryBuildingsAtPoint(lng, lat) {
|
||||
function queryBuildingsByReference(key, id) {
|
||||
if (key === 'toid'){
|
||||
return db.manyOrNone(
|
||||
"SELECT * FROM buildings WHERE b.ref_toid = $1",
|
||||
`SELECT
|
||||
*
|
||||
FROM
|
||||
buildings
|
||||
WHERE
|
||||
ref_toid = $1
|
||||
`,
|
||||
[id]
|
||||
).catch(function(error){
|
||||
console.error(error);
|
||||
@ -49,8 +55,10 @@ function queryBuildingsByReference(key, id) {
|
||||
}
|
||||
if (key === 'uprn') {
|
||||
return db.manyOrNone(
|
||||
`SELECT b.*
|
||||
FROM buildings as b, building_properties as p
|
||||
`SELECT
|
||||
b.*
|
||||
FROM
|
||||
buildings as b, building_properties as p
|
||||
WHERE
|
||||
b.building_id = p.building_id
|
||||
AND
|
||||
|
@ -177,11 +177,7 @@ server.route('/building/:building_id.json')
|
||||
.get(function (req, res) {
|
||||
const { building_id } = req.params;
|
||||
getBuildingById(building_id).then(function(result){
|
||||
if (result && result.length) {
|
||||
res.send(result)
|
||||
} else {
|
||||
res.status(404).send({error:'Not Found'})
|
||||
}
|
||||
res.send(result);
|
||||
}).catch(function(error){
|
||||
console.error(error);
|
||||
res.send({error:'Database error'})
|
||||
|
Loading…
Reference in New Issue
Block a user