From 8ab2ca41d5d5a0d0aefabeec0c6f062699c7ab06 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 24 Apr 2024 09:54:10 +0100 Subject: [PATCH] Added array parsing for search query config --- .../src/api/controllers/row/utils/utils.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/server/src/api/controllers/row/utils/utils.ts b/packages/server/src/api/controllers/row/utils/utils.ts index 7eb4901ded..962756ff87 100644 --- a/packages/server/src/api/controllers/row/utils/utils.ts +++ b/packages/server/src/api/controllers/row/utils/utils.ts @@ -190,6 +190,23 @@ export function isUserMetadataTable(tableId: string) { return tableId === InternalTables.USER_METADATA } +export async function enrichArrayContext( + fields: any[], + inputs = {}, + helpers = true +): Promise { + const map: Record = {} + for (let index in fields) { + map[index] = fields[index] + } + const output = await enrichSearchContext(map, inputs, helpers) + const outputArray: any[] = [] + for (let [key, value] of Object.entries(output)) { + outputArray[parseInt(key)] = value + } + return outputArray +} + export async function enrichSearchContext( fields: Record, inputs = {}, @@ -200,6 +217,11 @@ export async function enrichSearchContext( return enrichedQuery } const parameters = { ...inputs } + + if (Array.isArray(fields)) { + return enrichArrayContext(fields, inputs, helpers) + } + // enrich the fields with dynamic parameters for (let key of Object.keys(fields)) { if (fields[key] == null) {