From e29d7512e4fe2c6f7890fa5dc1fddbbeaf369438 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 12 May 2021 14:44:47 +0100 Subject: [PATCH] Updating search endpoint to have egress processing. --- packages/server/src/api/controllers/search/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/search/index.js b/packages/server/src/api/controllers/search/index.js index 2a309cc7e6..31c81fec9a 100644 --- a/packages/server/src/api/controllers/search/index.js +++ b/packages/server/src/api/controllers/search/index.js @@ -1,4 +1,6 @@ const { QueryBuilder, buildSearchUrl, search } = require("./utils") +const CouchDB = require("../../../db") +const { outputProcessing } = require("../../../utilities/rowProcessor") exports.rowSearch = async ctx => { const appId = ctx.appId @@ -12,6 +14,8 @@ exports.rowSearch = async ctx => { sortOrder, sortType, } = ctx.request.body + const db = new CouchDB(appId) + let url if (query) { url = new QueryBuilder( @@ -32,5 +36,10 @@ exports.rowSearch = async ctx => { bookmark, }) } - ctx.body = await search(url) + const response = await search(url) + const table = await db.get(tableId) + ctx.body = { + rows: await outputProcessing(appId, table, response.rows), + bookmark: response.bookmark, + } }