Browse Source

fix: check model defined/not before it's getting used and throw error

pull/6466/head
Pranav C 12 months ago
parent
commit
14c3bdf712
  1. 4
      packages/nocodb/src/modules/datas/helpers.ts

4
packages/nocodb/src/modules/datas/helpers.ts

@ -36,13 +36,15 @@ export async function getViewAndModelByAliasOrId(param: {
project_id: project.id,
aliasOrId: param.tableName,
});
if (!model) NcError.notFound('Table not found');
const view =
param.viewName &&
(await View.getByTitleOrId({
titleOrId: param.viewName,
fk_model_id: model.id,
}));
if (!model) NcError.notFound('Table not found');
if (param.viewName && !view) NcError.notFound('View not found');
return { model, view };
}

Loading…
Cancel
Save