Use helper
This commit is contained in:
parent
24463bd387
commit
c5f504d724
|
@ -2,7 +2,7 @@ import {
|
|||
Datasource,
|
||||
DocumentType,
|
||||
FieldType,
|
||||
LogicalOperator,
|
||||
isLogicalSearchOperator,
|
||||
Operation,
|
||||
QueryJson,
|
||||
RelationshipFieldMetadata,
|
||||
|
@ -141,10 +141,7 @@ function cleanupFilters(
|
|||
|
||||
const prefixFilters = (filters: SearchFilters) => {
|
||||
for (const filterKey of Object.keys(filters) as (keyof SearchFilters)[]) {
|
||||
if (
|
||||
filterKey === LogicalOperator.AND ||
|
||||
filterKey === LogicalOperator.OR
|
||||
) {
|
||||
if (isLogicalSearchOperator(filterKey)) {
|
||||
for (const condition of filters[filterKey]!.conditions) {
|
||||
prefixFilters(condition)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
BasicOperator,
|
||||
RangeOperator,
|
||||
LogicalOperator,
|
||||
isLogicalSearchOperator,
|
||||
} from "@budibase/types"
|
||||
import dayjs from "dayjs"
|
||||
import { OperatorOptions, SqlNumberTypeRangeMap } from "./constants"
|
||||
|
@ -359,10 +360,7 @@ export const buildQuery = (filter: SearchFilter[]) => {
|
|||
high: value,
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
queryOperator === LogicalOperator.AND ||
|
||||
queryOperator === LogicalOperator.OR
|
||||
) {
|
||||
} else if (isLogicalSearchOperator(queryOperator)) {
|
||||
// TODO
|
||||
} else if (query[queryOperator] && operator !== "onEmptyFilter") {
|
||||
if (type === "boolean") {
|
||||
|
@ -464,10 +462,9 @@ export const runQuery = (docs: Record<string, any>[], query: SearchFilters) => {
|
|||
) =>
|
||||
(doc: Record<string, any>) => {
|
||||
for (const [key, testValue] of Object.entries(query[type] || {})) {
|
||||
const valueToCheck =
|
||||
type === LogicalOperator.AND || type === LogicalOperator.OR
|
||||
? doc
|
||||
: deepGet(doc, removeKeyNumbering(key))
|
||||
const valueToCheck = isLogicalSearchOperator(type)
|
||||
? doc
|
||||
: deepGet(doc, removeKeyNumbering(key))
|
||||
const result = test(valueToCheck, testValue)
|
||||
if (query.allOr && result) {
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue