Browse Source

feat: OldDatasService - dataRead

pull/5444/head
Wing-Kam Wong 2 years ago committed by Pranav C
parent
commit
ff53699734
  1. 25
      packages/nocodb-nest/src/modules/datas/old-datas/old-datas.service.ts

25
packages/nocodb-nest/src/modules/datas/old-datas/old-datas.service.ts

@ -75,6 +75,31 @@ export class OldDatasService {
return await baseModel.insert(param.body, null, param); return await baseModel.insert(param.body, null, param);
} }
async dataRead(param: PathParams & { query: any; rowId: string }) {
const { model, view } = await this.getViewAndModelFromRequest(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 { ast } = await getAst({
query: param.query,
model,
view,
});
return await nocoExecute(
ast,
await baseModel.readByPk(param.params.rowId),
{},
{},
);
}
async getViewAndModelFromRequest(req) { async getViewAndModelFromRequest(req) {
const project = await Project.getWithInfo(req.params.projectId); const project = await Project.getWithInfo(req.params.projectId);
const model = await Model.getByAliasOrId({ const model = await Model.getByAliasOrId({

Loading…
Cancel
Save