24 lines
730 B
JavaScript
24 lines
730 B
JavaScript
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;
|
|
};
|
|
// 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]+ ")\'))");
|
|
}
|
|
|
|
module.exports = {
|
|
currentRERequest,
|
|
allRERequest,
|
|
findPointInsideBoundingBox
|
|
};
|