Filters done
This commit is contained in:
@@ -21,6 +21,8 @@ router.get('/search', async (req, res, next) => {
|
||||
const maxSize = req.query.maxSize;
|
||||
const rooms = req.query.rooms;
|
||||
const adType = req.query.adType;
|
||||
const category = req.query.category;
|
||||
const sort = req.query.sort;
|
||||
const properties = db.collection('listings');
|
||||
let query = {};
|
||||
|
||||
@@ -93,6 +95,19 @@ router.get('/search', async (req, res, next) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (category) {
|
||||
const allCategories = category.split(',');
|
||||
const or = allCategories.map(val => {
|
||||
return {
|
||||
category: parseInt(val)
|
||||
};
|
||||
});
|
||||
|
||||
query = Object.assign(query, {
|
||||
"$or": or
|
||||
});
|
||||
}
|
||||
|
||||
console.log('QUERY: ', query);
|
||||
const all = await properties.find(query, {
|
||||
//"sort": [['field1','asc'], ['field2','desc']]
|
||||
|
||||
Reference in New Issue
Block a user