Files
old-web/app/helpers/url.js

24 lines
730 B
JavaScript
Raw Normal View History

2019-04-27 07:08:36 +02:00
const db = require('../models/index');
const currentRERequest = async (req) => {
const uniqueId = req.params['request_id'];
if(!uniqueId) return null;
const request = await db.RealEstateRequest.findOne({ where: {uniqueId} });
return request;
2019-05-16 19:58:48 +02:00
};
2019-06-20 14:51:14 +02:00
// TODO Fetch only subscribed realestate requests
const allRERequest = async () => {
return await db.RealEstateRequest.findAll();
}
const findPointInsideBoundingBox = async (latLng) => {
return await db.sequelize.query("SELECT * FROM \"RealEstateRequests\" WHERE ST_Contains(\"RealEstateRequests\".bounding_box, ST_GEOMFROMTEXT(\'POINT (" + latLng[0] + " " + latLng[1]+ ")\'))");
}
2019-04-27 07:08:36 +02:00
module.exports = {
currentRERequest,
allRERequest,
findPointInsideBoundingBox
2019-05-16 19:58:48 +02:00
};