Search by location dates
This commit is contained in:
parent
b1c77ba9c5
commit
3b1a86f393
@ -1,6 +1,20 @@
|
||||
class Utils {
|
||||
static makeVehiclesSearchQuery(queryParams, email) {
|
||||
const { query, brand, model, color, regions, fromDate, toDate, addedBy, fromDateUpdated, toDateUpdated, year } = queryParams;
|
||||
const {
|
||||
query,
|
||||
brand,
|
||||
model,
|
||||
color,
|
||||
regions,
|
||||
fromDate,
|
||||
toDate,
|
||||
addedBy,
|
||||
fromDateUpdated,
|
||||
toDateUpdated,
|
||||
fromLocationDate,
|
||||
toLocationDate,
|
||||
year
|
||||
} = queryParams;
|
||||
|
||||
let numberQuery = Utils.makeNumberQuery(query, regions?.split(',') ?? []);
|
||||
let findQuery = {
|
||||
@ -33,6 +47,22 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
if(fromLocationDate || toLocationDate) {
|
||||
let comparator = {};
|
||||
if(fromLocationDate) {
|
||||
comparator.$gte = parseFloat(fromLocationDate);
|
||||
}
|
||||
if(toLocationDate) {
|
||||
comparator.$lte = parseFloat(toLocationDate);
|
||||
}
|
||||
|
||||
findQuery.events = {
|
||||
$elemMatch: {
|
||||
date: comparator
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if(addedBy) {
|
||||
if(addedBy == 'me') {
|
||||
findQuery.addedBy = email;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user