diff --git a/packages/nocodb/src/helpers/NcPluginMgrv2.ts b/packages/nocodb/src/helpers/NcPluginMgrv2.ts index 6abd44b949..50215ec941 100644 --- a/packages/nocodb/src/helpers/NcPluginMgrv2.ts +++ b/packages/nocodb/src/helpers/NcPluginMgrv2.ts @@ -162,7 +162,7 @@ class NcPluginMgrv2 { public static async storageAdapter( ncMeta = Noco.ncMeta, ): Promise { - const pluginData = await ncMeta.metaGet2( + const pluginData = await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.PLUGIN, @@ -192,7 +192,7 @@ class NcPluginMgrv2 { isUserInvite = true, ncMeta = Noco.ncMeta, ): Promise { - const pluginData = await ncMeta.metaGet2( + const pluginData = await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.PLUGIN, @@ -227,7 +227,7 @@ class NcPluginMgrv2 { title: string, ncMeta = Noco.ncMeta, ): Promise { - const pluginData = await ncMeta.metaGet2( + const pluginData = await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.PLUGIN, diff --git a/packages/nocodb/src/meta/meta.service.ts b/packages/nocodb/src/meta/meta.service.ts index 7eba9a7215..5347b76097 100644 --- a/packages/nocodb/src/meta/meta.service.ts +++ b/packages/nocodb/src/meta/meta.service.ts @@ -84,9 +84,55 @@ export class MetaService { target: string, idOrCondition: string | { [p: string]: any }, fields?: string[], - // xcCondition? + xcCondition?: Condition, ): Promise { - return this.metaGet2(workspace_id, base_id, target, idOrCondition, fields); + const query = this.knexConnection(target); + + if (xcCondition) { + query.condition(xcCondition); + } + + if (fields?.length) { + query.select(...fields); + } + + if (workspace_id === RootScopes.BYPASS && base_id === RootScopes.BYPASS) { + // bypass + } else if (workspace_id === base_id) { + if (!Object.values(RootScopes).includes(workspace_id as RootScopes)) { + NcError.metaError({ + message: 'Invalid scope', + sql: '', + }); + } + + if (!RootScopeTables[workspace_id].includes(target)) { + NcError.metaError({ + message: 'Table not accessible from this scope', + sql: '', + }); + } + } else { + if (!base_id) { + NcError.metaError({ + message: 'Base ID is required', + sql: '', + }); + } + + this.contextCondition(query, workspace_id, base_id, target); + } + + if (!idOrCondition) { + return query.first(); + } + + if (typeof idOrCondition !== 'object') { + query.where('id', idOrCondition); + } else { + query.where(idOrCondition); + } + return query.first(); } /*** @@ -326,72 +372,6 @@ export class MetaService { return query.del(); } - /*** - * Get meta data - * @param workspace_id - Workspace id - * @param base_id - Base id - * @param target - Table name - * @param idOrCondition - If string, will get the record with the given id. If object, will get the record with the given condition. - * @param fields - Fields to be selected - * @param xcCondition - Additional nested or complex condition to be added to the query. - */ - public async metaGet2( - workspace_id: string, - base_id: string, - target: string, - idOrCondition: string | { [p: string]: any }, - fields?: string[], - xcCondition?: Condition, - ): Promise { - const query = this.knexConnection(target); - - if (xcCondition) { - query.condition(xcCondition); - } - - if (fields?.length) { - query.select(...fields); - } - - if (workspace_id === RootScopes.BYPASS && base_id === RootScopes.BYPASS) { - // bypass - } else if (workspace_id === base_id) { - if (!Object.values(RootScopes).includes(workspace_id as RootScopes)) { - NcError.metaError({ - message: 'Invalid scope', - sql: '', - }); - } - - if (!RootScopeTables[workspace_id].includes(target)) { - NcError.metaError({ - message: 'Table not accessible from this scope', - sql: '', - }); - } - } else { - if (!base_id) { - NcError.metaError({ - message: 'Base ID is required', - sql: '', - }); - } - - this.contextCondition(query, workspace_id, base_id, target); - } - - if (!idOrCondition) { - return query.first(); - } - - if (typeof idOrCondition !== 'object') { - query.where('id', idOrCondition); - } else { - query.where(idOrCondition); - } - return query.first(); - } - /*** * Get order value for the next record * @param target - Table name diff --git a/packages/nocodb/src/models/Audit.ts b/packages/nocodb/src/models/Audit.ts index 873356d01e..045d5568f3 100644 --- a/packages/nocodb/src/models/Audit.ts +++ b/packages/nocodb/src/models/Audit.ts @@ -65,7 +65,7 @@ export default class Audit implements AuditType { } public static async get(auditId: string) { - const audit = await Noco.ncMeta.metaGet2( + const audit = await Noco.ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.AUDIT, diff --git a/packages/nocodb/src/models/BarcodeColumn.ts b/packages/nocodb/src/models/BarcodeColumn.ts index 33cf9f4a1a..5a82b9b3d4 100644 --- a/packages/nocodb/src/models/BarcodeColumn.ts +++ b/packages/nocodb/src/models/BarcodeColumn.ts @@ -63,7 +63,7 @@ export default class BarcodeColumn { CacheGetType.TYPE_OBJECT, )); if (!column) { - column = await ncMeta.metaGet2( + column = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COL_BARCODE, diff --git a/packages/nocodb/src/models/Base.ts b/packages/nocodb/src/models/Base.ts index f046f528f8..ebbb89e39b 100644 --- a/packages/nocodb/src/models/Base.ts +++ b/packages/nocodb/src/models/Base.ts @@ -175,7 +175,7 @@ export default class Base implements BaseType { CacheGetType.TYPE_OBJECT, )); if (!baseData) { - baseData = await ncMeta.metaGet2( + baseData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.PROJECT, @@ -219,7 +219,7 @@ export default class Base implements BaseType { )); if (!baseData) { - baseData = await ncMeta.metaGet2( + baseData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.PROJECT, @@ -431,7 +431,7 @@ export default class Base implements BaseType { )); let baseData = null; if (!baseId) { - baseData = await Noco.ncMeta.metaGet2( + baseData = await Noco.ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.PROJECT, @@ -478,7 +478,7 @@ export default class Base implements BaseType { )); let baseData = null; if (!baseId) { - baseData = await ncMeta.metaGet2( + baseData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.PROJECT, @@ -513,7 +513,7 @@ export default class Base implements BaseType { )); let baseData = null; if (!baseId) { - baseData = await ncMeta.metaGet2( + baseData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.PROJECT, diff --git a/packages/nocodb/src/models/CalendarRange.ts b/packages/nocodb/src/models/CalendarRange.ts index 6422841f68..b950cd3487 100644 --- a/packages/nocodb/src/models/CalendarRange.ts +++ b/packages/nocodb/src/models/CalendarRange.ts @@ -99,7 +99,7 @@ export default class CalendarRange implements CalendarRangeType { fk_view_id: string, ncMeta = Noco.ncMeta, ): Promise { - const data = await ncMeta.metaGet2( + const data = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.CALENDAR_VIEW_RANGE, diff --git a/packages/nocodb/src/models/CalendarView.ts b/packages/nocodb/src/models/CalendarView.ts index c2a59f35ac..4956d69563 100644 --- a/packages/nocodb/src/models/CalendarView.ts +++ b/packages/nocodb/src/models/CalendarView.ts @@ -47,7 +47,7 @@ export default class CalendarView implements CalendarType { view.calendar_range = []; } } else { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.CALENDAR_VIEW, diff --git a/packages/nocodb/src/models/CalendarViewColumn.ts b/packages/nocodb/src/models/CalendarViewColumn.ts index 44366cc590..6d20b587b4 100644 --- a/packages/nocodb/src/models/CalendarViewColumn.ts +++ b/packages/nocodb/src/models/CalendarViewColumn.ts @@ -37,7 +37,7 @@ export default class CalendarViewColumn { CacheGetType.TYPE_OBJECT, )); if (!viewColumn) { - viewColumn = await ncMeta.metaGet2( + viewColumn = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.CALENDAR_VIEW_COLUMNS, diff --git a/packages/nocodb/src/models/Column.ts b/packages/nocodb/src/models/Column.ts index 56bf2212d7..d90c7e3f6e 100644 --- a/packages/nocodb/src/models/Column.ts +++ b/packages/nocodb/src/models/Column.ts @@ -635,7 +635,7 @@ export default class Column implements ColumnType { CacheGetType.TYPE_OBJECT, )); if (!colData) { - colData = await ncMeta.metaGet2( + colData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COLUMNS, @@ -1311,7 +1311,7 @@ export default class Column implements ColumnType { }: { column_name; fk_model_id; exclude_id? }, ncMeta = Noco.ncMeta, ) { - return !(await ncMeta.metaGet2( + return !(await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COLUMNS, @@ -1329,7 +1329,7 @@ export default class Column implements ColumnType { { title, fk_model_id, exclude_id }: { title; fk_model_id; exclude_id? }, ncMeta = Noco.ncMeta, ) { - return !(await ncMeta.metaGet2( + return !(await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COLUMNS, diff --git a/packages/nocodb/src/models/Comment.ts b/packages/nocodb/src/models/Comment.ts index 9d4b2666dd..550345ccf7 100644 --- a/packages/nocodb/src/models/Comment.ts +++ b/packages/nocodb/src/models/Comment.ts @@ -31,7 +31,7 @@ export default class Comment implements CommentType { commentId: string, ncMeta = Noco.ncMeta, ) { - const comment = await ncMeta.metaGet2( + const comment = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COMMENTS, diff --git a/packages/nocodb/src/models/Extension.ts b/packages/nocodb/src/models/Extension.ts index 9af5928c47..f8d2fb4985 100644 --- a/packages/nocodb/src/models/Extension.ts +++ b/packages/nocodb/src/models/Extension.ts @@ -36,7 +36,7 @@ export default class Extension { ); if (!extension) { - extension = await ncMeta.metaGet2( + extension = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.EXTENSIONS, diff --git a/packages/nocodb/src/models/Filter.ts b/packages/nocodb/src/models/Filter.ts index 1835cc5b24..48b4044fad 100644 --- a/packages/nocodb/src/models/Filter.ts +++ b/packages/nocodb/src/models/Filter.ts @@ -170,7 +170,7 @@ export default class Filter implements FilterType { let value = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); if (!value) { /* get from db */ - value = await ncMeta.metaGet2( + value = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.FILTER_EXP, @@ -363,7 +363,7 @@ export default class Filter implements FilterType { 2, ); if (!filterObj) { - filterObj = await ncMeta.metaGet2( + filterObj = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.FILTER_EXP, @@ -420,7 +420,7 @@ export default class Filter implements FilterType { // }): Promise { // if (!viewId) return null; // - // const filterObj = await ncMeta.metaGet2( + // const filterObj = await ncMeta.metaGet( // context.workspace_id, // context.base_id, // MetaTable.FILTER_EXP, @@ -586,7 +586,7 @@ export default class Filter implements FilterType { CacheGetType.TYPE_OBJECT, )); if (!filterObj) { - filterObj = await ncMeta.metaGet2( + filterObj = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.FILTER_EXP, diff --git a/packages/nocodb/src/models/FormView.ts b/packages/nocodb/src/models/FormView.ts index 6dfc767e1a..d2e25ebedb 100644 --- a/packages/nocodb/src/models/FormView.ts +++ b/packages/nocodb/src/models/FormView.ts @@ -59,7 +59,7 @@ export default class FormView implements FormViewType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.FORM_VIEW, diff --git a/packages/nocodb/src/models/FormViewColumn.ts b/packages/nocodb/src/models/FormViewColumn.ts index 634dbc4da3..fc913bf811 100644 --- a/packages/nocodb/src/models/FormViewColumn.ts +++ b/packages/nocodb/src/models/FormViewColumn.ts @@ -46,7 +46,7 @@ export default class FormViewColumn implements FormColumnType { CacheGetType.TYPE_OBJECT, )); if (!viewColumn) { - viewColumn = await ncMeta.metaGet2( + viewColumn = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.FORM_VIEW_COLUMNS, diff --git a/packages/nocodb/src/models/FormulaColumn.ts b/packages/nocodb/src/models/FormulaColumn.ts index 041e98008f..6ad5e66b62 100644 --- a/packages/nocodb/src/models/FormulaColumn.ts +++ b/packages/nocodb/src/models/FormulaColumn.ts @@ -57,7 +57,7 @@ export default class FormulaColumn { CacheGetType.TYPE_OBJECT, )); if (!column) { - column = await ncMeta.metaGet2( + column = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COL_FORMULA, diff --git a/packages/nocodb/src/models/GalleryView.ts b/packages/nocodb/src/models/GalleryView.ts index 8e5f4f0968..e34216cc4e 100644 --- a/packages/nocodb/src/models/GalleryView.ts +++ b/packages/nocodb/src/models/GalleryView.ts @@ -57,7 +57,7 @@ export default class GalleryView implements GalleryType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.GALLERY_VIEW, diff --git a/packages/nocodb/src/models/GalleryViewColumn.ts b/packages/nocodb/src/models/GalleryViewColumn.ts index 1c80bde4a5..c1f03284ad 100644 --- a/packages/nocodb/src/models/GalleryViewColumn.ts +++ b/packages/nocodb/src/models/GalleryViewColumn.ts @@ -34,7 +34,7 @@ export default class GalleryViewColumn { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.GALLERY_VIEW_COLUMNS, diff --git a/packages/nocodb/src/models/GridView.ts b/packages/nocodb/src/models/GridView.ts index 025e942121..4e2cb6d5e4 100644 --- a/packages/nocodb/src/models/GridView.ts +++ b/packages/nocodb/src/models/GridView.ts @@ -37,7 +37,7 @@ export default class GridView implements GridType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.GRID_VIEW, diff --git a/packages/nocodb/src/models/GridViewColumn.ts b/packages/nocodb/src/models/GridViewColumn.ts index 5f56bfb910..80e3f7ffdf 100644 --- a/packages/nocodb/src/models/GridViewColumn.ts +++ b/packages/nocodb/src/models/GridViewColumn.ts @@ -74,7 +74,7 @@ export default class GridViewColumn implements GridColumnType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.GRID_VIEW_COLUMNS, diff --git a/packages/nocodb/src/models/Hook.ts b/packages/nocodb/src/models/Hook.ts index bb0818518a..9c7ccd9c21 100644 --- a/packages/nocodb/src/models/Hook.ts +++ b/packages/nocodb/src/models/Hook.ts @@ -55,7 +55,7 @@ export default class Hook implements HookType { CacheGetType.TYPE_OBJECT, )); if (!hook) { - hook = await ncMeta.metaGet2( + hook = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.HOOKS, diff --git a/packages/nocodb/src/models/HookFilter.ts b/packages/nocodb/src/models/HookFilter.ts index 43873a5d5b..2d5d2dd769 100644 --- a/packages/nocodb/src/models/HookFilter.ts +++ b/packages/nocodb/src/models/HookFilter.ts @@ -114,7 +114,7 @@ export default class Filter { let value = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); if (!value) { /* get from db */ - value = await ncMeta.metaGet2( + value = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.FILTER_EXP, @@ -230,7 +230,7 @@ export default class Filter { // 2 // ); // if (!filterObj) { - // filterObj = await ncMeta.metaGet2(context.workspace_id, context.base_id, MetaTable.FILTER_EXP, { + // filterObj = await ncMeta.metaGet(context.workspace_id, context.base_id, MetaTable.FILTER_EXP, { // id: this.fk_parent_id // }); // await NocoCache.set( @@ -277,7 +277,7 @@ export default class Filter { // }): Promise { // if (!viewId) return null; // - // const filterObj = await ncMeta.metaGet2( + // const filterObj = await ncMeta.metaGet( // context.workspace_id, // context.base_id, // MetaTable.FILTER_EXP, @@ -381,7 +381,7 @@ export default class Filter { CacheGetType.TYPE_OBJECT, )); if (!filterObj) { - filterObj = await ncMeta.metaGet2( + filterObj = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.FILTER_EXP, diff --git a/packages/nocodb/src/models/KanbanView.ts b/packages/nocodb/src/models/KanbanView.ts index c2b49f80a0..d51dc201e0 100644 --- a/packages/nocodb/src/models/KanbanView.ts +++ b/packages/nocodb/src/models/KanbanView.ts @@ -48,7 +48,7 @@ export default class KanbanView implements KanbanType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.KANBAN_VIEW, diff --git a/packages/nocodb/src/models/KanbanViewColumn.ts b/packages/nocodb/src/models/KanbanViewColumn.ts index 07cd41ebf2..05f21695e3 100644 --- a/packages/nocodb/src/models/KanbanViewColumn.ts +++ b/packages/nocodb/src/models/KanbanViewColumn.ts @@ -34,7 +34,7 @@ export default class KanbanViewColumn implements KanbanColumnType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.KANBAN_VIEW_COLUMNS, diff --git a/packages/nocodb/src/models/LinkToAnotherRecordColumn.ts b/packages/nocodb/src/models/LinkToAnotherRecordColumn.ts index d114e1403c..0359b4890a 100644 --- a/packages/nocodb/src/models/LinkToAnotherRecordColumn.ts +++ b/packages/nocodb/src/models/LinkToAnotherRecordColumn.ts @@ -172,7 +172,7 @@ export default class LinkToAnotherRecordColumn { CacheGetType.TYPE_OBJECT, )); if (!colData) { - colData = await ncMeta.metaGet2( + colData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COL_RELATIONS, diff --git a/packages/nocodb/src/models/LookupColumn.ts b/packages/nocodb/src/models/LookupColumn.ts index 50f7f6296f..e6803b2e67 100644 --- a/packages/nocodb/src/models/LookupColumn.ts +++ b/packages/nocodb/src/models/LookupColumn.ts @@ -76,7 +76,7 @@ export default class LookupColumn implements LookupType { CacheGetType.TYPE_OBJECT, )); if (!colData) { - colData = await ncMeta.metaGet2( + colData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COL_LOOKUP, diff --git a/packages/nocodb/src/models/MapView.ts b/packages/nocodb/src/models/MapView.ts index 7b60e7007d..5d95b371e2 100644 --- a/packages/nocodb/src/models/MapView.ts +++ b/packages/nocodb/src/models/MapView.ts @@ -42,7 +42,7 @@ export default class MapView implements MapType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MAP_VIEW, diff --git a/packages/nocodb/src/models/MapViewColumn.ts b/packages/nocodb/src/models/MapViewColumn.ts index 24f02f273e..52b6ae6ac7 100644 --- a/packages/nocodb/src/models/MapViewColumn.ts +++ b/packages/nocodb/src/models/MapViewColumn.ts @@ -33,7 +33,7 @@ export default class MapViewColumn { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MAP_VIEW_COLUMNS, diff --git a/packages/nocodb/src/models/Model.ts b/packages/nocodb/src/models/Model.ts index 40a3248635..0d69fe815c 100644 --- a/packages/nocodb/src/models/Model.ts +++ b/packages/nocodb/src/models/Model.ts @@ -348,7 +348,7 @@ export default class Model implements TableType { CacheGetType.TYPE_OBJECT, )); if (!modelData) { - modelData = await ncMeta.metaGet2( + modelData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MODELS, @@ -384,7 +384,7 @@ export default class Model implements TableType { CacheGetType.TYPE_OBJECT, )); if (!modelData) { - modelData = await ncMeta.metaGet2( + modelData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MODELS, @@ -420,7 +420,7 @@ export default class Model implements TableType { CacheGetType.TYPE_OBJECT, )); if (!modelData) { - modelData = await ncMeta.metaGet2( + modelData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MODELS, @@ -976,7 +976,7 @@ export default class Model implements TableType { (await NocoCache.get(cacheKey, CacheGetType.TYPE_STRING)); if (!modelId) { const model = source_id - ? await ncMeta.metaGet2( + ? await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MODELS, @@ -997,7 +997,7 @@ export default class Model implements TableType { ], }, ) - : await ncMeta.metaGet2( + : await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MODELS, @@ -1032,7 +1032,7 @@ export default class Model implements TableType { { table_name, exclude_id }: { table_name; base_id; source_id; exclude_id? }, ncMeta = Noco.ncMeta, ) { - return !(await ncMeta.metaGet2( + return !(await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MODELS, @@ -1049,7 +1049,7 @@ export default class Model implements TableType { { title, exclude_id }: { title; base_id; source_id; exclude_id? }, ncMeta = Noco.ncMeta, ) { - return !(await ncMeta.metaGet2( + return !(await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MODELS, diff --git a/packages/nocodb/src/models/ModelRoleVisibility.ts b/packages/nocodb/src/models/ModelRoleVisibility.ts index 29822e2d77..a89d991f5f 100644 --- a/packages/nocodb/src/models/ModelRoleVisibility.ts +++ b/packages/nocodb/src/models/ModelRoleVisibility.ts @@ -64,7 +64,7 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType { CacheGetType.TYPE_OBJECT, )); if (!data) { - data = await ncMeta.metaGet2( + data = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.MODEL_ROLE_VISIBILITY, diff --git a/packages/nocodb/src/models/Notification.ts b/packages/nocodb/src/models/Notification.ts index c41b8f6c2f..ffabd55455 100644 --- a/packages/nocodb/src/models/Notification.ts +++ b/packages/nocodb/src/models/Notification.ts @@ -47,7 +47,7 @@ export default class Notification { ) { const condition = extractProps(params, ['id', 'fk_user_id']); - return await ncMeta.metaGet2( + return await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.NOTIFICATION, diff --git a/packages/nocodb/src/models/Plugin.ts b/packages/nocodb/src/models/Plugin.ts index 37ab8072bb..c95148eacb 100644 --- a/packages/nocodb/src/models/Plugin.ts +++ b/packages/nocodb/src/models/Plugin.ts @@ -41,7 +41,7 @@ export default class Plugin implements PluginType { CacheGetType.TYPE_OBJECT, )); if (!plugin) { - plugin = await ncMeta.metaGet2( + plugin = await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.PLUGIN, @@ -109,7 +109,7 @@ export default class Plugin implements PluginType { CacheGetType.TYPE_OBJECT, )); if (!plugin) { - plugin = await ncMeta.metaGet2( + plugin = await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.PLUGIN, diff --git a/packages/nocodb/src/models/QrCodeColumn.ts b/packages/nocodb/src/models/QrCodeColumn.ts index 1b2672deb0..344ab541fd 100644 --- a/packages/nocodb/src/models/QrCodeColumn.ts +++ b/packages/nocodb/src/models/QrCodeColumn.ts @@ -59,7 +59,7 @@ export default class QrCodeColumn { CacheGetType.TYPE_OBJECT, )); if (!column) { - column = await ncMeta.metaGet2( + column = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COL_QRCODE, diff --git a/packages/nocodb/src/models/RollupColumn.ts b/packages/nocodb/src/models/RollupColumn.ts index 6978471256..128ceef281 100644 --- a/packages/nocodb/src/models/RollupColumn.ts +++ b/packages/nocodb/src/models/RollupColumn.ts @@ -92,7 +92,7 @@ export default class RollupColumn implements RollupType { CacheGetType.TYPE_OBJECT, )); if (!column) { - column = await ncMeta.metaGet2( + column = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COL_ROLLUP, diff --git a/packages/nocodb/src/models/SelectOption.ts b/packages/nocodb/src/models/SelectOption.ts index 7fa30fd0fe..20e0e5aae4 100644 --- a/packages/nocodb/src/models/SelectOption.ts +++ b/packages/nocodb/src/models/SelectOption.ts @@ -115,7 +115,7 @@ export default class SelectOption implements SelectOptionType { CacheGetType.TYPE_OBJECT, )); if (!data) { - data = await ncMeta.metaGet2( + data = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COL_SELECT_OPTIONS, @@ -168,7 +168,7 @@ export default class SelectOption implements SelectOptionType { title: string, ncMeta = Noco.ncMeta, ): Promise { - const data = await ncMeta.metaGet2( + const data = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COL_SELECT_OPTIONS, diff --git a/packages/nocodb/src/models/Sort.ts b/packages/nocodb/src/models/Sort.ts index cffb21c439..ebbdb5d193 100644 --- a/packages/nocodb/src/models/Sort.ts +++ b/packages/nocodb/src/models/Sort.ts @@ -271,7 +271,7 @@ export default class Sort { CacheGetType.TYPE_OBJECT, )); if (!sortData) { - sortData = await ncMeta.metaGet2( + sortData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.SORT, diff --git a/packages/nocodb/src/models/Source.ts b/packages/nocodb/src/models/Source.ts index cd77f22547..a1786e207a 100644 --- a/packages/nocodb/src/models/Source.ts +++ b/packages/nocodb/src/models/Source.ts @@ -272,7 +272,7 @@ export default class Source implements SourceType { CacheGetType.TYPE_OBJECT, )); if (!baseData) { - baseData = await ncMeta.metaGet2( + baseData = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.BASES, @@ -310,7 +310,7 @@ export default class Source implements SourceType { uuid: string, ncMeta = Noco.ncMeta, ) { - const source = await ncMeta.metaGet2( + const source = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.BASES, diff --git a/packages/nocodb/src/models/SyncSource.ts b/packages/nocodb/src/models/SyncSource.ts index 93d5e3293a..f54b76be57 100644 --- a/packages/nocodb/src/models/SyncSource.ts +++ b/packages/nocodb/src/models/SyncSource.ts @@ -30,7 +30,7 @@ export default class SyncSource { syncSourceId: string, ncMeta = Noco.ncMeta, ) { - const syncSource = await ncMeta.metaGet2( + const syncSource = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.SYNC_SOURCE, diff --git a/packages/nocodb/src/models/User.ts b/packages/nocodb/src/models/User.ts index 6b3b0e8544..478b582788 100644 --- a/packages/nocodb/src/models/User.ts +++ b/packages/nocodb/src/models/User.ts @@ -145,7 +145,7 @@ export default class User implements UserType { CacheGetType.TYPE_OBJECT, )); if (!user) { - user = await ncMeta.metaGet2( + user = await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.USERS, @@ -159,7 +159,7 @@ export default class User implements UserType { } static async isFirst(ncMeta = Noco.ncMeta) { - return !(await ncMeta.metaGet2( + return !(await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.USERS, @@ -192,7 +192,7 @@ export default class User implements UserType { CacheGetType.TYPE_OBJECT, )); if (!user) { - user = await ncMeta.metaGet2( + user = await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.USERS, @@ -213,7 +213,7 @@ export default class User implements UserType { return null; } - return await ncMeta.metaGet2( + return await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.USERS, diff --git a/packages/nocodb/src/models/UserRefreshToken.ts b/packages/nocodb/src/models/UserRefreshToken.ts index 2d629c3e0c..8f8b63fb45 100644 --- a/packages/nocodb/src/models/UserRefreshToken.ts +++ b/packages/nocodb/src/models/UserRefreshToken.ts @@ -114,7 +114,7 @@ export default class UserRefreshToken { token: string, ncMeta = Noco.ncMeta, ): Promise { - const userToken = await ncMeta.metaGet2( + const userToken = await ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.USER_REFRESH_TOKENS, diff --git a/packages/nocodb/src/models/View.ts b/packages/nocodb/src/models/View.ts index 45f381f24b..516ebd8c16 100644 --- a/packages/nocodb/src/models/View.ts +++ b/packages/nocodb/src/models/View.ts @@ -111,7 +111,7 @@ export default class View implements ViewType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.VIEWS, @@ -138,7 +138,7 @@ export default class View implements ViewType { CacheGetType.TYPE_STRING, )); if (!viewId) { - const view = await ncMeta.metaGet2( + const view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.VIEWS, @@ -189,7 +189,7 @@ export default class View implements ViewType { CacheGetType.TYPE_OBJECT, )); if (!view) { - view = await ncMeta.metaGet2( + view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.VIEWS, @@ -880,7 +880,7 @@ export default class View implements ViewType { const o = await NocoCache.get(key, CacheGetType.TYPE_STRING); if (o) return o; - const viewColumn = await ncMeta.metaGet2( + const viewColumn = await ncMeta.metaGet( context.workspace_id, context.base_id, tableName, @@ -941,7 +941,7 @@ export default class View implements ViewType { // keep primary_value_column always visible and first in grid view if (view.type === ViewTypes.GRID) { - const primary_value_column_meta = await ncMeta.metaGet2( + const primary_value_column_meta = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COLUMNS, @@ -951,7 +951,7 @@ export default class View implements ViewType { }, ); - const primary_value_column = await ncMeta.metaGet2( + const primary_value_column = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.GRID_VIEW_COLUMNS, @@ -1010,7 +1010,7 @@ export default class View implements ViewType { const view = await this.get(context, viewId, ncMeta); const table = this.extractViewColumnsTableName(view); - const existingCol = await ncMeta.metaGet2( + const existingCol = await ncMeta.metaGet( context.workspace_id, context.base_id, table, @@ -1131,7 +1131,7 @@ export default class View implements ViewType { uuid: string, ncMeta = Noco.ncMeta, ) { - const view = await ncMeta.metaGet2( + const view = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.VIEWS, @@ -1487,7 +1487,7 @@ export default class View implements ViewType { const scope = this.extractViewColumnsTableNameScope(view); if (view.type === ViewTypes.GRID) { - const primary_value_column = await ncMeta.metaGet2( + const primary_value_column = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COLUMNS, @@ -1604,7 +1604,7 @@ export default class View implements ViewType { // get column meta for each view column for (const col of view_columns) { - const col_meta = await ncMeta.metaGet2( + const col_meta = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.COLUMNS, diff --git a/packages/nocodb/src/services/base-users/base-users.service.ts b/packages/nocodb/src/services/base-users/base-users.service.ts index a873e46e7f..a825881c92 100644 --- a/packages/nocodb/src/services/base-users/base-users.service.ts +++ b/packages/nocodb/src/services/base-users/base-users.service.ts @@ -333,7 +333,7 @@ export class BaseUsersService { invite_token_expires: new Date(Date.now() + 24 * 60 * 60 * 1000), }); - const pluginData = await Noco.ncMeta.metaGet2( + const pluginData = await Noco.ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.PLUGIN, diff --git a/packages/nocodb/src/services/org-users.service.ts b/packages/nocodb/src/services/org-users.service.ts index d3a386aa13..a3e5b53e4e 100644 --- a/packages/nocodb/src/services/org-users.service.ts +++ b/packages/nocodb/src/services/org-users.service.ts @@ -218,7 +218,7 @@ export class OrgUsersService { invite_token_expires: new Date(Date.now() + 24 * 60 * 60 * 1000), }); - const pluginData = await Noco.ncMeta.metaGet2( + const pluginData = await Noco.ncMeta.metaGet( RootScopes.ROOT, RootScopes.ROOT, MetaTable.PLUGIN, diff --git a/packages/nocodb/src/services/view-columns.service.ts b/packages/nocodb/src/services/view-columns.service.ts index 4859bf5476..27439e81b0 100644 --- a/packages/nocodb/src/services/view-columns.service.ts +++ b/packages/nocodb/src/services/view-columns.service.ts @@ -141,7 +141,7 @@ export class ViewColumnsService { const columnId = typeof param.columns === 'object' ? indexOrId : column['id']; - const existingCol = await ncMeta.metaGet2( + const existingCol = await ncMeta.metaGet( context.workspace_id, context.base_id, table, diff --git a/packages/nocodb/src/utils/cloud/populateCloudPlugins.ts b/packages/nocodb/src/utils/cloud/populateCloudPlugins.ts index 36924422ca..b1fedb7cec 100644 --- a/packages/nocodb/src/utils/cloud/populateCloudPlugins.ts +++ b/packages/nocodb/src/utils/cloud/populateCloudPlugins.ts @@ -13,9 +13,14 @@ export const populatePluginsForCloud = async ({ ncMeta = Noco.ncMeta }) => { throw new Error('S3 env variables not found'); } - const s3PluginData = await ncMeta.metaGet2(null, null, MetaTable.PLUGIN, { - title: S3PluginConfig.title, - }); + const s3PluginData = await ncMeta.metaGet( + RootScopes.ROOT, + RootScopes.ROOT, + MetaTable.PLUGIN, + { + title: S3PluginConfig.title, + }, + ); if (!s3PluginData) throw new Error('S3 plugin not found'); @@ -57,9 +62,14 @@ export const populatePluginsForCloud = async ({ ncMeta = Noco.ncMeta }) => { // throw new Error('SES env variables not found'); // } - const sesPluginData = await ncMeta.metaGet2(null, null, MetaTable.PLUGIN, { - title: SESPluginConfig.title, - }); + const sesPluginData = await ncMeta.metaGet( + RootScopes.ROOT, + RootScopes.ROOT, + MetaTable.PLUGIN, + { + title: SESPluginConfig.title, + }, + ); if (!sesPluginData) throw new Error('SES plugin not found'); diff --git a/packages/nocodb/src/version-upgrader/ncAttachmentUpgrader.ts b/packages/nocodb/src/version-upgrader/ncAttachmentUpgrader.ts index 5a7a66f96e..813a5f1d8f 100644 --- a/packages/nocodb/src/version-upgrader/ncAttachmentUpgrader.ts +++ b/packages/nocodb/src/version-upgrader/ncAttachmentUpgrader.ts @@ -61,7 +61,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) { base_id: source.base_id, }; - const base = await ncMeta.metaGet2( + const base = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.PROJECT, diff --git a/packages/nocodb/src/version-upgrader/ncAttachmentUpgrader_0104002.ts b/packages/nocodb/src/version-upgrader/ncAttachmentUpgrader_0104002.ts index 5d57a046d5..1c3d5e876c 100644 --- a/packages/nocodb/src/version-upgrader/ncAttachmentUpgrader_0104002.ts +++ b/packages/nocodb/src/version-upgrader/ncAttachmentUpgrader_0104002.ts @@ -52,7 +52,7 @@ export default async function ({ ncMeta }: NcUpgraderCtx) { base_id: source.base_id, }; - const base = await ncMeta.metaGet2( + const base = await ncMeta.metaGet( context.workspace_id, context.base_id, MetaTable.PROJECT,