Browse Source

feat: allow reusing baseModel for getDataList

Signed-off-by: mertmit <mertmit99@gmail.com>
feat/export-nest-dir-restructure
mertmit 2 years ago committed by starbirdtech383
parent
commit
797d7e092e
  1. 20
      packages/nocodb-nest/src/services/datas.service.ts

20
packages/nocodb-nest/src/services/datas.service.ts

@ -13,6 +13,7 @@ import {
getViewAndModelByAliasOrId, getViewAndModelByAliasOrId,
serializeCellValue, serializeCellValue,
} from '../modules/datas/helpers'; } from '../modules/datas/helpers';
import type { BaseModelSqlv2 } from '../db/BaseModelSqlv2';
import type { PathParams } from '../modules/datas/helpers'; import type { PathParams } from '../modules/datas/helpers';
import type { LinkToAnotherRecordColumn, LookupColumn } from '../models'; import type { LinkToAnotherRecordColumn, LookupColumn } from '../models';
@ -110,16 +111,23 @@ export class DatasService {
return await baseModel.delByPk(param.rowId, null, param.cookie); 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 { model, view, query = {} } = param;
const base = await Base.get(model.base_id); const base = await Base.get(model.base_id);
const baseModel = await Model.getBaseModelSQL({ const baseModel =
id: model.id, param.baseModel ||
viewId: view?.id, (await Model.getBaseModelSQL({
dbDriver: await NcConnectionMgrv2.get(base), id: model.id,
}); viewId: view?.id,
dbDriver: await NcConnectionMgrv2.get(base),
}));
const { ast, dependencyFields } = await getAst({ model, query, view }); const { ast, dependencyFields } = await getAst({ model, query, view });

Loading…
Cancel
Save