WiP - changed db helpers

This commit is contained in:
Naida Vatric
2019-12-11 01:24:18 +01:00
parent 6f729b4135
commit dee7c6000a
2 changed files with 79 additions and 4 deletions

View File

@@ -43,6 +43,11 @@ const findSearchRequestsForRealEstate = async realEstate => {
adType,
realEstateType,
subscribed: true,
//
accessRoadType,
balcony,
newBuilding,
elevator,
[Op.and]: geoSearchQueryPart
};
@@ -63,7 +68,39 @@ const findSearchRequestsForRealEstate = async realEstate => {
[Op.gte]: area
};
}
//
if (gardenSize) {
query.gardenSizeMin = {
[Op.lte]: gardenSize
};
query.gardenSizeMax = {
[Op.gte]: gardenSize
};
}
if (numberOfRooms) {
query.numberOfRoomsMin = {
[Op.lte]: numberOfRooms
};
query.numberOfRoomsMax = {
[Op.gte]: numberOfRooms
};
}
if (numberOfFloors) {
query.numberOfFloorsMin = {
[Op.lte]: numberOfFloors
};
query.numberOfFloorsMax = {
[Op.gte]: numberOfFloors
};
}
if (floor) {
query.floorMin = {
[Op.lte]: floor
};
query.floorMax = {
[Op.gte]: floor
};
}
return await db.SearchRequest.findAll({ where: query });
};