From 6e10c528d89a8204d8ff8fe8e4dfe8958aca37bc Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 9 Sep 2024 16:25:34 +0100 Subject: [PATCH] Getting rid of findInDoc as its not used anymore. --- packages/shared-core/src/filters.ts | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 70fb24b373..bcd2e0e338 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -471,15 +471,8 @@ export const search = ( * Performs a client-side search on an array of data * @param docs the data * @param query the JSON query - * @param findInDoc optional fn when trying to extract a value - * from custom doc type e.g. Google Sheets - * */ -export const runQuery = ( - docs: Record[], - query: SearchFilters, - findInDoc: Function = deepGet -) => { +export const runQuery = (docs: Record[], query: SearchFilters) => { if (!docs || !Array.isArray(docs)) { return [] } @@ -503,11 +496,8 @@ export const runQuery = ( test: (docValue: any, testValue: any) => boolean ) => (doc: Record) => { - for (const [key, testValue] of Object.entries(query[type] || {})) { - const valueToCheck = isLogicalSearchOperator(type) - ? doc - : findInDoc(doc, removeKeyNumbering(key)) - const result = test(valueToCheck, testValue) + for (const testValue of Object.values(query[type] || {})) { + const result = test(doc, testValue) if (query.allOr && result) { return true } else if (!query.allOr && !result) {