Browse Source

feat: meta reading

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/655/head
Pranav C 3 years ago
parent
commit
dc5d16024e
  1. 28
      packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts

28
packages/nocodb/src/lib/noco/meta/NcMetaMgrEE.ts

@ -135,8 +135,19 @@ export default class NcMetaMgrEE extends NcMetaMgr {
?.apiBuilders?.find(ab => ab.dbAlias === viewMeta.db_alias);
const model = apiBuilder?.xcModels?.[viewMeta.model_name];
if (model) {
let meta = apiBuilder?.getMeta(viewMeta.model_name);
if (!model) {
throw new Error('Meta not found');
}
const queryParams = JSON.parse(viewMeta.query_params);
if (!meta) throw new Error('Meta not found');
meta = {
...meta,
columns: meta.columns.filter(c => queryParams?.showFields?.[c._cn])
};
let where = '';
if (req.query.where) {
@ -151,7 +162,7 @@ export default class NcMetaMgrEE extends NcMetaMgr {
return {
model_name: viewMeta.model_name,
meta: JSON.parse(viewMeta.meta),
meta,
data: await model.list({
...req.query,
where,
@ -164,7 +175,6 @@ export default class NcMetaMgrEE extends NcMetaMgr {
})),
client: apiBuilder?.client
};
}
} catch (e) {
throw e;
}
@ -173,12 +183,12 @@ export default class NcMetaMgrEE extends NcMetaMgr {
protected async createSharedViewLink(req, args: any): Promise<any> {
try {
// todo: keep belongs to column if belongs to virtual column present
if (args.args.query_params?.fields && args.args.show_as !== 'form') {
const fields = args.args.query_params?.fields.split(',');
args.args.meta.columns = args.args.meta.columns.filter(c =>
fields.includes(c._cn)
);
}
// if (args.args.query_params?.fields && args.args.show_as !== 'form') {
// const fields = args.args.query_params?.fields.split(',');
// args.args.meta.columns = args.args.meta.columns.filter(c =>
// fields.includes(c._cn)
// );
// }
const insertData = {
project_id: args.project_id,

Loading…
Cancel
Save