From 98d9f52f66cdfc44f58d84342e24a12d701d5e33 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 6 Aug 2024 08:09:20 +0200 Subject: [PATCH] Fix shared-core build --- packages/shared-core/src/filters.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index d30f591abc..f4e40f50cb 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -17,6 +17,7 @@ import { Table, BasicOperator, RangeOperator, + LogicalOperator, } from "@budibase/types" import dayjs from "dayjs" import { OperatorOptions, SqlNumberTypeRangeMap } from "./constants" @@ -358,6 +359,11 @@ export const buildQuery = (filter: SearchFilter[]) => { high: value, } } + } else if ( + queryOperator === LogicalOperator.AND || + queryOperator === LogicalOperator.OR + ) { + // TODO } else if (query[queryOperator] && operator !== "onEmptyFilter") { if (type === "boolean") { // Transform boolean filters to cope with null. @@ -666,8 +672,26 @@ export const runQuery = (docs: Record[], query: SearchFilters) => { ) const containsAny = match(ArrayOperator.CONTAINS_ANY, _contains("some")) + const and = match( + LogicalOperator.AND, + (_docValue: Record, _testValue: any) => { + // TODO + return false + } + ) + const or = match( + LogicalOperator.AND, + (_docValue: Record, _testValue: any) => { + // TODO + return false + } + ) + const docMatch = (doc: Record) => { - const filterFunctions = { + const filterFunctions: Record< + SearchFilterOperator, + (doc: Record) => boolean + > = { string: stringMatch, fuzzy: fuzzyMatch, range: rangeMatch, @@ -679,6 +703,8 @@ export const runQuery = (docs: Record[], query: SearchFilters) => { contains: contains, containsAny: containsAny, notContains: notContains, + [LogicalOperator.AND]: and, + [LogicalOperator.OR]: or, } const results = Object.entries(query || {})