exports.findOne = (req, res) => {
Geodata.find({'osmname':req.query.osmname}).select({'osm_way_id':req.body.osm_way_id,'osmname':req.body.osmname,'geometry':req.body.geometry}).lean()
.then(geotable => {
if(!geotable) {
return res.status(404).send({
message: "record not found " + req.query.osmname
});
}
res.json(geotable);
}).catch(err => {
if(err.kind === 'osmname') {
return res.status(404).send({
message: "record not found " + req.query.osmname
});
}
return res.status(500).send({
message: "something wrong with name " + req.query.osmname
});
});
};
// for get api
module.exports = (app) => {
///onlty app.get with query params not working in browser but working in postman.
app.get('/geodata/osmname', geodata.findOne);
}