From 3cf96c589cd102958529d88c2b806f238aa3cd4d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 9 Oct 2024 10:33:15 +0200 Subject: [PATCH] Implement logical conditions --- packages/shared-core/src/utils.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/shared-core/src/utils.ts b/packages/shared-core/src/utils.ts index 14b3c84425..4847e911e9 100644 --- a/packages/shared-core/src/utils.ts +++ b/packages/shared-core/src/utils.ts @@ -5,6 +5,7 @@ import { SearchFilters, BasicOperator, ArrayOperator, + isLogicalSearchOperator, } from "@budibase/types" import * as Constants from "./constants" import { removeKeyNumbering } from "./filters" @@ -97,10 +98,20 @@ export function isSupportedUserSearch(query: SearchFilters) { { op: BasicOperator.EQUAL, key: "_id" }, { op: ArrayOperator.ONE_OF, key: "_id" }, ] - for (let [key, operation] of Object.entries(query)) { + for (const [key, operation] of Object.entries(query)) { if (typeof operation !== "object") { return false } + + if (isLogicalSearchOperator(key)) { + for (const condition of query[key]!.conditions) { + if (!isSupportedUserSearch(condition)) { + return false + } + } + return true + } + const fields = Object.keys(operation || {}) // this filter doesn't contain options - ignore if (fields.length === 0) {