Handle marker icons

This commit is contained in:
Edin Dazdarevic
2017-04-06 01:11:51 +02:00
parent e3e5b4ac96
commit 6905695958
6 changed files with 150 additions and 28 deletions

View File

@@ -74,7 +74,7 @@
router.get('/search', function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(req, res, next) {
var bounds, minPrice, maxPrice, minSize, maxSize, rooms, adType, category, sort, properties, query, _bounds$split$map, _bounds$split$map2, lat1, lng1, lat2, lng2, box, price, allRooms, or, size, allCategories, _or, all;
var bounds, minPrice, maxPrice, minSize, maxSize, rooms, adType, category, sort, properties, query, _bounds$split$map, _bounds$split$map2, lat1, lng1, lat2, lng2, box, price, and, allRooms, or, size, allCategories, _or, all;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
@@ -130,6 +130,8 @@
});
}
and = [];
if (rooms) {
allRooms = rooms.split(',');
or = allRooms.map(function (val) {
@@ -146,9 +148,10 @@
});
query = Object.assign(query, {
"$or": or
});
and.push({ "$or": or });
//query = Object.assign(query, {
//rooms:
//});
}
if (minSize || maxSize) {
@@ -176,40 +179,47 @@
});
and.push({ "$or": _or });
//query = Object.assign(query, {
//{"$or" : or }
//});
}
if (and.length > 0) {
query = Object.assign(query, {
"$or": _or
"$and": and
});
}
console.log('QUERY: ', query);
_context.next = 21;
_context.next = 23;
return properties.find(query, {
//"sort": [['field1','asc'], ['field2','desc']]
"sort": [['price', 'asc']]
}).toArray();
case 21:
case 23:
all = _context.sent;
res.json(all);
res.end();
_context.next = 30;
_context.next = 32;
break;
case 26:
_context.prev = 26;
case 28:
_context.prev = 28;
_context.t0 = _context['catch'](0);
console.log('error:', _context.t0);
next(_context.t0);
case 30:
case 32:
case 'end':
return _context.stop();
}
}
}, _callee, undefined, [[0, 26]]);
}, _callee, undefined, [[0, 28]]);
}));
return function (_x, _x2, _x3) {

View File

@@ -60,6 +60,7 @@ router.get('/search', async (req, res, next) => {
});
}
const and = [];
if (rooms) {
const allRooms = rooms.split(',');
const or = allRooms.map(val => {
@@ -75,9 +76,7 @@ router.get('/search', async (req, res, next) => {
};
});
query = Object.assign(query, {
"$or": or
});
and.push({ "$or": or });
}
if (minSize || maxSize) {
@@ -103,8 +102,12 @@ router.get('/search', async (req, res, next) => {
};
});
and.push({ "$or": or });
}
if (and.length > 0) {
query = Object.assign(query, {
"$or": or
"$and": and
});
}