Add support for gt / gte / lt / lte

This commit is contained in:
rijkvanzanten
2020-08-12 18:27:55 -04:00
parent d02f302ac6
commit 93e18a8e96

View File

@@ -50,7 +50,7 @@ export function applyFilter(dbQuery: QueryBuilder, filter: Filter) {
if (key.startsWith('_') === false) {
let operator = Object.keys(value)[0];
const compareValue = Object.values(value)[0];
const compareValue: any = Object.values(value)[0];
if (operator === '_eq') {
dbQuery.where({ [key]: compareValue });
@@ -68,6 +68,22 @@ export function applyFilter(dbQuery: QueryBuilder, filter: Filter) {
dbQuery.where(key, 'like', `%${compareValue}%`);
}
if (operator === '_gt') {
dbQuery.where(key, '>', compareValue);
}
if (operator === '_gte') {
dbQuery.where(key, '>=', compareValue);
}
if (operator === '_lt') {
dbQuery.where(key, '<', compareValue);
}
if (operator === '_lte') {
dbQuery.where(key, '<=', compareValue);
}
if (operator === '_in') {
let value = compareValue;
if (typeof value === 'string') value = value.split(',');