Getting rid of findInDoc as its not used anymore.

This commit is contained in:
mike12345567 2024-09-09 16:25:34 +01:00
parent ee968b212a
commit 6e10c528d8
1 changed files with 3 additions and 13 deletions

View File

@ -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<string, any>[],
query: SearchFilters,
findInDoc: Function = deepGet
) => {
export const runQuery = (docs: Record<string, any>[], query: SearchFilters) => {
if (!docs || !Array.isArray(docs)) {
return []
}
@ -503,11 +496,8 @@ export const runQuery = (
test: (docValue: any, testValue: any) => boolean
) =>
(doc: Record<string, any>) => {
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) {