Changed to avoid falsy values and not defined realestate parametrs.
This commit is contained in:
@@ -175,8 +175,8 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
[Op.and]: geoSearchQueryPart
|
||||
};
|
||||
|
||||
//Every other attribute is checked separately and included in query only if it is defined
|
||||
if (gardenSizeMax && gardenSizeMin) {
|
||||
//Every other attribute is checked separately and included in query only if it is defined/not null
|
||||
if (gardenSizeMax!=null && gardenSizeMin!=null) {
|
||||
query.gardenSize = {
|
||||
[Op.lte]: gardenSizeMax,
|
||||
[Op.gte]: gardenSizeMin
|
||||
@@ -192,7 +192,7 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (numberOfRoomsMin && numberOfRoomsMax) {
|
||||
if (numberOfRoomsMin!=null && numberOfRoomsMax!=null) {
|
||||
query.numberOfRooms = {
|
||||
[Op.lte]: numberOfRoomsMax,
|
||||
[Op.gte]: numberOfRoomsMin
|
||||
@@ -208,7 +208,7 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (numberOfFloorsMin && numberOfFloorsMax) {
|
||||
if (numberOfFloorsMin!=null && numberOfFloorsMax!=null) {
|
||||
query.numberOfFloors = {
|
||||
[Op.lte]: numberOfFloorsMax,
|
||||
[Op.gte]: numberOfFloorsMin
|
||||
@@ -224,7 +224,7 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (floorMin && floorMax) {
|
||||
if (floorMin!=null && floorMax!=null) {
|
||||
query.floor = {
|
||||
[Op.lte]: floorMax,
|
||||
[Op.gte]: floorMin
|
||||
@@ -240,7 +240,7 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (balcony) {
|
||||
if (balcony!=null) {
|
||||
query.balcony = {
|
||||
[Op.eq]: balcony
|
||||
};
|
||||
@@ -252,7 +252,7 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (newBuilding) {
|
||||
if (newBuilding!=null) {
|
||||
query.newBuilding = {
|
||||
[Op.eq]: newBuilding
|
||||
};
|
||||
@@ -264,7 +264,7 @@ const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (elevator) {
|
||||
if (elevator!=null) {
|
||||
query.elevator = {
|
||||
[Op.eq]: elevator
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user