Browse Source

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

pull/6466/head
Pranav C 1 year 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, project_id: project.id,
aliasOrId: param.tableName, aliasOrId: param.tableName,
}); });
if (!model) NcError.notFound('Table not found');
const view = const view =
param.viewName && param.viewName &&
(await View.getByTitleOrId({ (await View.getByTitleOrId({
titleOrId: param.viewName, titleOrId: param.viewName,
fk_model_id: model.id, fk_model_id: model.id,
})); }));
if (!model) NcError.notFound('Table not found');
if (param.viewName && !view) NcError.notFound('View not found'); if (param.viewName && !view) NcError.notFound('View not found');
return { model, view }; return { model, view };
} }

Loading…
Cancel
Save