From 797d7e092e2cae98d482c45943d397f5d03efcbb Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 29 Apr 2023 17:33:07 +0300 Subject: [PATCH] feat: allow reusing baseModel for getDataList Signed-off-by: mertmit --- .../nocodb-nest/src/services/datas.service.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/nocodb-nest/src/services/datas.service.ts b/packages/nocodb-nest/src/services/datas.service.ts index bc9dbd0aee..1e1aa78d24 100644 --- a/packages/nocodb-nest/src/services/datas.service.ts +++ b/packages/nocodb-nest/src/services/datas.service.ts @@ -13,6 +13,7 @@ import { getViewAndModelByAliasOrId, serializeCellValue, } from '../modules/datas/helpers'; +import type { BaseModelSqlv2 } from '../db/BaseModelSqlv2'; import type { PathParams } from '../modules/datas/helpers'; import type { LinkToAnotherRecordColumn, LookupColumn } from '../models'; @@ -110,16 +111,23 @@ export class DatasService { return await baseModel.delByPk(param.rowId, null, param.cookie); } - async getDataList(param: { model: Model; view: View; query: any }) { + async getDataList(param: { + model: Model; + view: View; + query: any; + baseModel?: BaseModelSqlv2; + }) { const { model, view, query = {} } = param; const base = await Base.get(model.base_id); - const baseModel = await Model.getBaseModelSQL({ - id: model.id, - viewId: view?.id, - dbDriver: await NcConnectionMgrv2.get(base), - }); + const baseModel = + param.baseModel || + (await Model.getBaseModelSQL({ + id: model.id, + viewId: view?.id, + dbDriver: await NcConnectionMgrv2.get(base), + })); const { ast, dependencyFields } = await getAst({ model, query, view });