Getting rid of findInDoc as its not used anymore.
This commit is contained in:
parent
ee968b212a
commit
6e10c528d8
|
@ -471,15 +471,8 @@ export const search = (
|
||||||
* Performs a client-side search on an array of data
|
* Performs a client-side search on an array of data
|
||||||
* @param docs the data
|
* @param docs the data
|
||||||
* @param query the JSON query
|
* @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 = (
|
export const runQuery = (docs: Record<string, any>[], query: SearchFilters) => {
|
||||||
docs: Record<string, any>[],
|
|
||||||
query: SearchFilters,
|
|
||||||
findInDoc: Function = deepGet
|
|
||||||
) => {
|
|
||||||
if (!docs || !Array.isArray(docs)) {
|
if (!docs || !Array.isArray(docs)) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
@ -503,11 +496,8 @@ export const runQuery = (
|
||||||
test: (docValue: any, testValue: any) => boolean
|
test: (docValue: any, testValue: any) => boolean
|
||||||
) =>
|
) =>
|
||||||
(doc: Record<string, any>) => {
|
(doc: Record<string, any>) => {
|
||||||
for (const [key, testValue] of Object.entries(query[type] || {})) {
|
for (const testValue of Object.values(query[type] || {})) {
|
||||||
const valueToCheck = isLogicalSearchOperator(type)
|
const result = test(doc, testValue)
|
||||||
? doc
|
|
||||||
: findInDoc(doc, removeKeyNumbering(key))
|
|
||||||
const result = test(valueToCheck, testValue)
|
|
||||||
if (query.allOr && result) {
|
if (query.allOr && result) {
|
||||||
return true
|
return true
|
||||||
} else if (!query.allOr && !result) {
|
} else if (!query.allOr && !result) {
|
||||||
|
|
Loading…
Reference in New Issue