diff --git a/packages/nocodb-nest/src/models/Base.ts b/packages/nocodb-nest/src/models/Base.ts
index fd92ee44e1..2846b3b7b4 100644
--- a/packages/nocodb-nest/src/models/Base.ts
+++ b/packages/nocodb-nest/src/models/Base.ts
@@ -153,10 +153,12 @@ export default class Base implements BaseType {
args: { projectId: string },
ncMeta = Noco.ncMeta,
): Promise {
- let baseDataList = await NocoCache.getList(CacheScope.BASE, [
+ const cachedList = await NocoCache.getList(CacheScope.BASE, [
args.projectId,
]);
- if (!baseDataList.length) {
+ let { list: baseDataList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !baseDataList.length) {
baseDataList = await ncMeta.metaList2(
args.projectId,
null,
diff --git a/packages/nocodb-nest/src/models/Column.ts b/packages/nocodb-nest/src/models/Column.ts
index 063be50c97..22ed522e37 100644
--- a/packages/nocodb-nest/src/models/Column.ts
+++ b/packages/nocodb-nest/src/models/Column.ts
@@ -474,8 +474,12 @@ export default class Column implements ColumnType {
},
ncMeta = Noco.ncMeta,
): Promise {
- let columnsList = await NocoCache.getList(CacheScope.COLUMN, [fk_model_id]);
- if (!columnsList.length) {
+ const cachedList = await NocoCache.getList(CacheScope.COLUMN, [
+ fk_model_id,
+ ]);
+ let { list: columnsList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !columnsList.length) {
columnsList = await ncMeta.metaList2(null, null, MetaTable.COLUMNS, {
condition: {
fk_model_id,
@@ -627,8 +631,10 @@ export default class Column implements ColumnType {
// get lookup columns and delete
{
- let lookups = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]);
- if (!lookups.length) {
+ const cachedList = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]);
+ let { list: lookups } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !lookups.length) {
lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, {
condition: { fk_lookup_column_id: id },
});
@@ -640,8 +646,10 @@ export default class Column implements ColumnType {
// get rollup column and delete
{
- let rollups = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]);
- if (!rollups.length) {
+ const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]);
+ let { list: rollups } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !rollups.length) {
rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, {
condition: { fk_rollup_column_id: id },
});
@@ -652,10 +660,12 @@ export default class Column implements ColumnType {
}
{
- let formulaColumns = await NocoCache.getList(CacheScope.COLUMN, [
+ const cachedList = await NocoCache.getList(CacheScope.COLUMN, [
col.fk_model_id,
]);
- if (!formulaColumns.length) {
+ let { list: formulaColumns } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !formulaColumns.length) {
formulaColumns = await ncMeta.metaList2(null, null, MetaTable.COLUMNS, {
condition: {
fk_model_id: col.fk_model_id,
@@ -682,33 +692,43 @@ export default class Column implements ColumnType {
// if relation column check lookup and rollup and delete
if (col.uidt === UITypes.LinkToAnotherRecord) {
- // get lookup columns using relation and delete
- let lookups = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]);
- if (!lookups.length) {
- lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, {
- condition: { fk_relation_column_id: id },
- });
- }
- for (const lookup of lookups) {
- await Column.delete(lookup.fk_column_id, ncMeta);
+ {
+ // get lookup columns using relation and delete
+ const cachedList = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]);
+ let { list: lookups } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !lookups.length) {
+ lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, {
+ condition: { fk_relation_column_id: id },
+ });
+ }
+ for (const lookup of lookups) {
+ await Column.delete(lookup.fk_column_id, ncMeta);
+ }
}
- // get rollup columns using relation and delete
- let rollups = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]);
- if (!rollups.length) {
- rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, {
- condition: { fk_relation_column_id: id },
- });
- }
- for (const rollup of rollups) {
- await Column.delete(rollup.fk_column_id, ncMeta);
+ {
+ // get rollup columns using relation and delete
+ const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]);
+ let { list: rollups } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !rollups.length) {
+ rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, {
+ condition: { fk_relation_column_id: id },
+ });
+ }
+ for (const rollup of rollups) {
+ await Column.delete(rollup.fk_column_id, ncMeta);
+ }
}
}
// delete sorts
{
- let sorts = await NocoCache.getList(CacheScope.SORT, [id]);
- if (!sorts.length) {
+ const cachedList = await NocoCache.getList(CacheScope.SORT, [id]);
+ let { list: sorts } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !sorts.length) {
sorts = await ncMeta.metaList2(null, null, MetaTable.SORT, {
condition: {
fk_column_id: id,
@@ -721,8 +741,10 @@ export default class Column implements ColumnType {
}
// delete filters
{
- let filters = await NocoCache.getList(CacheScope.FILTER_EXP, [id]);
- if (!filters.length) {
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [id]);
+ let { list: filters } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !filters.length) {
filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: {
fk_column_id: id,
diff --git a/packages/nocodb-nest/src/models/Filter.ts b/packages/nocodb-nest/src/models/Filter.ts
index 20000e9762..1c94b35352 100644
--- a/packages/nocodb-nest/src/models/Filter.ts
+++ b/packages/nocodb-nest/src/models/Filter.ts
@@ -326,10 +326,12 @@ export default class Filter implements FilterType {
public async getChildren(ncMeta = Noco.ncMeta): Promise {
if (this.children) return this.children;
if (!this.is_group) return null;
- let childFilters = await NocoCache.getList(CacheScope.FILTER_EXP, [
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [
this.id,
]);
- if (!childFilters.length) {
+ let { list: childFilters } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !childFilters.length) {
childFilters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: {
fk_parent_id: this.id,
@@ -369,10 +371,12 @@ export default class Filter implements FilterType {
},
ncMeta = Noco.ncMeta,
): Promise {
- let filters = await NocoCache.getList(CacheScope.FILTER_EXP, [
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [
viewId || hookId,
]);
- if (!filters.length) {
+ let { list: filters } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !filters.length) {
filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: viewId ? { fk_view_id: viewId } : { fk_hook_id: hookId },
orderBy: {
@@ -480,8 +484,10 @@ export default class Filter implements FilterType {
{ viewId }: { viewId: any },
ncMeta = Noco.ncMeta,
) {
- let filterObjs = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]);
- if (!filterObjs.length) {
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]);
+ let { list: filterObjs } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !filterObjs.length) {
filterObjs = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: { fk_view_id: viewId },
orderBy: {
@@ -499,8 +505,10 @@ export default class Filter implements FilterType {
{ hookId }: { hookId: any },
ncMeta = Noco.ncMeta,
) {
- let filterObjs = await NocoCache.getList(CacheScope.FILTER_EXP, [hookId]);
- if (!filterObjs.length) {
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [hookId]);
+ let { list: filterObjs } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !filterObjs.length) {
filterObjs = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: { fk_hook_id: hookId },
orderBy: {
@@ -520,8 +528,12 @@ export default class Filter implements FilterType {
},
ncMeta = Noco.ncMeta,
) {
- let filterObjs = await NocoCache.getList(CacheScope.FILTER_EXP, [parentId]);
- if (!filterObjs.length) {
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [
+ parentId,
+ ]);
+ let { list: filterObjs } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !filterObjs.length) {
filterObjs = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: {
fk_parent_id: parentId,
@@ -546,11 +558,13 @@ export default class Filter implements FilterType {
},
ncMeta = Noco.ncMeta,
) {
- let filterObjs = await NocoCache.getList(CacheScope.FILTER_EXP, [
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [
hookId,
parentId,
]);
- if (!filterObjs.length) {
+ let { list: filterObjs } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !filterObjs.length) {
filterObjs = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: {
fk_parent_id: parentId,
diff --git a/packages/nocodb-nest/src/models/FormViewColumn.ts b/packages/nocodb-nest/src/models/FormViewColumn.ts
index 5cf1b24778..157e4bd5bc 100644
--- a/packages/nocodb-nest/src/models/FormViewColumn.ts
+++ b/packages/nocodb-nest/src/models/FormViewColumn.ts
@@ -100,13 +100,11 @@ export default class FormViewColumn implements FormColumnType {
await NocoCache.set(`${CacheScope.FORM_VIEW_COLUMN}:${fk_column_id}`, id);
// if cache is not present skip pushing it into the list to avoid unexpected behaviour
- if (
- (
- await NocoCache.getList(CacheScope.FORM_VIEW_COLUMN, [
- column.fk_view_id,
- ])
- )?.length
- )
+ const { list } = await NocoCache.getList(CacheScope.FORM_VIEW_COLUMN, [
+ column.fk_view_id,
+ ]);
+
+ if (list?.length)
await NocoCache.appendToList(
CacheScope.FORM_VIEW_COLUMN,
[column.fk_view_id],
@@ -119,10 +117,12 @@ export default class FormViewColumn implements FormColumnType {
viewId: string,
ncMeta = Noco.ncMeta,
): Promise {
- let viewColumns = await NocoCache.getList(CacheScope.FORM_VIEW_COLUMN, [
+ const cachedList = await NocoCache.getList(CacheScope.FORM_VIEW_COLUMN, [
viewId,
]);
- if (!viewColumns.length) {
+ let { list: viewColumns } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !viewColumns.length) {
viewColumns = await ncMeta.metaList2(
null,
null,
diff --git a/packages/nocodb-nest/src/models/GalleryViewColumn.ts b/packages/nocodb-nest/src/models/GalleryViewColumn.ts
index d235e567da..6aaa63d89f 100644
--- a/packages/nocodb-nest/src/models/GalleryViewColumn.ts
+++ b/packages/nocodb-nest/src/models/GalleryViewColumn.ts
@@ -79,13 +79,11 @@ export default class GalleryViewColumn {
);
// if cache is not present skip pushing it into the list to avoid unexpected behaviour
- if (
- (
- await NocoCache.getList(CacheScope.GALLERY_VIEW_COLUMN, [
- column.fk_view_id,
- ])
- )?.length
- )
+ const { list } = await NocoCache.getList(CacheScope.GALLERY_VIEW_COLUMN, [
+ column.fk_view_id,
+ ]);
+
+ if (list?.length)
await NocoCache.appendToList(
CacheScope.GALLERY_VIEW_COLUMN,
[column.fk_view_id],
@@ -99,10 +97,12 @@ export default class GalleryViewColumn {
viewId: string,
ncMeta = Noco.ncMeta,
): Promise {
- let views = await NocoCache.getList(CacheScope.GALLERY_VIEW_COLUMN, [
+ const cachedList = await NocoCache.getList(CacheScope.GALLERY_VIEW_COLUMN, [
viewId,
]);
- if (!views.length) {
+ let { list: views } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !views.length) {
views = await ncMeta.metaList2(
null,
null,
diff --git a/packages/nocodb-nest/src/models/GridViewColumn.ts b/packages/nocodb-nest/src/models/GridViewColumn.ts
index aedae667e8..d619bf7bf5 100644
--- a/packages/nocodb-nest/src/models/GridViewColumn.ts
+++ b/packages/nocodb-nest/src/models/GridViewColumn.ts
@@ -24,8 +24,12 @@ export default class GridViewColumn implements GridColumnType {
viewId: string,
ncMeta = Noco.ncMeta,
): Promise {
- let views = await NocoCache.getList(CacheScope.GRID_VIEW_COLUMN, [viewId]);
- if (!views.length) {
+ const cachedList = await NocoCache.getList(CacheScope.GRID_VIEW_COLUMN, [
+ viewId,
+ ]);
+ let { list: views } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !views.length) {
views = await ncMeta.metaList2(null, null, MetaTable.GRID_VIEW_COLUMNS, {
condition: {
fk_view_id: viewId,
@@ -99,13 +103,10 @@ export default class GridViewColumn implements GridColumnType {
await NocoCache.set(`${CacheScope.GRID_VIEW_COLUMN}:${fk_column_id}`, id);
// if cache is not present skip pushing it into the list to avoid unexpected behaviour
- if (
- (
- await NocoCache.getList(CacheScope.GRID_VIEW_COLUMN, [
- column.fk_view_id,
- ])
- )?.length
- )
+ const { list } = await NocoCache.getList(CacheScope.GRID_VIEW_COLUMN, [
+ column.fk_view_id,
+ ]);
+ if (list.length)
await NocoCache.appendToList(
CacheScope.GRID_VIEW_COLUMN,
[column.fk_view_id],
diff --git a/packages/nocodb-nest/src/models/Hook.ts b/packages/nocodb-nest/src/models/Hook.ts
index e4b805eecc..31f5a8b462 100644
--- a/packages/nocodb-nest/src/models/Hook.ts
+++ b/packages/nocodb-nest/src/models/Hook.ts
@@ -85,8 +85,12 @@ export default class Hook implements HookType {
},
ncMeta = Noco.ncMeta,
) {
- let hooks = await NocoCache.getList(CacheScope.HOOK, [param.fk_model_id]);
- if (!hooks.length) {
+ const cachedList = await NocoCache.getList(CacheScope.HOOK, [
+ param.fk_model_id,
+ ]);
+ let { list: hooks } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !hooks.length) {
hooks = await ncMeta.metaList(null, null, MetaTable.HOOKS, {
condition: {
fk_model_id: param.fk_model_id,
diff --git a/packages/nocodb-nest/src/models/HookFilter.ts b/packages/nocodb-nest/src/models/HookFilter.ts
index 58ca44f42e..39aceaef46 100644
--- a/packages/nocodb-nest/src/models/HookFilter.ts
+++ b/packages/nocodb-nest/src/models/HookFilter.ts
@@ -205,10 +205,12 @@ export default class Filter {
public async getChildren(ncMeta = Noco.ncMeta): Promise {
if (this.children) return this.children;
if (!this.is_group) return null;
- let childFilters = await NocoCache.getList(CacheScope.FILTER_EXP, [
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [
this.id,
]);
- if (!childFilters.length) {
+ let { list: childFilters } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !childFilters.length) {
childFilters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: {
fk_parent_id: this.id,
@@ -243,8 +245,10 @@ export default class Filter {
},
ncMeta = Noco.ncMeta,
): Promise {
- let filters = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]);
- if (!filters.length) {
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]);
+ let { list: filters } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !filters.length) {
filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: { fk_view_id: viewId },
});
@@ -327,8 +331,10 @@ export default class Filter {
{ viewId }: { viewId: any },
ncMeta = Noco.ncMeta,
) {
- let filterObjs = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]);
- if (!filterObjs.length) {
+ const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]);
+ let { list: filterObjs } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !filterObjs.length) {
filterObjs = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: { fk_view_id: viewId },
});
diff --git a/packages/nocodb-nest/src/models/KanbanViewColumn.ts b/packages/nocodb-nest/src/models/KanbanViewColumn.ts
index 6171ec645f..47e731bca0 100644
--- a/packages/nocodb-nest/src/models/KanbanViewColumn.ts
+++ b/packages/nocodb-nest/src/models/KanbanViewColumn.ts
@@ -85,10 +85,12 @@ export default class KanbanViewColumn implements KanbanColumnType {
viewId: string,
ncMeta = Noco.ncMeta,
): Promise {
- let views = await NocoCache.getList(CacheScope.KANBAN_VIEW_COLUMN, [
+ const cachedList = await NocoCache.getList(CacheScope.KANBAN_VIEW_COLUMN, [
viewId,
]);
- if (!views.length) {
+ let { list: views } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !views.length) {
views = await ncMeta.metaList2(
null,
null,
diff --git a/packages/nocodb-nest/src/models/MapViewColumn.ts b/packages/nocodb-nest/src/models/MapViewColumn.ts
index 94d3c1e6ee..c48bc4ac41 100644
--- a/packages/nocodb-nest/src/models/MapViewColumn.ts
+++ b/packages/nocodb-nest/src/models/MapViewColumn.ts
@@ -67,10 +67,10 @@ export default class MapViewColumn {
await NocoCache.set(`${CacheScope.MAP_VIEW_COLUMN}:${fk_column_id}`, id);
// if cache is not present skip pushing it into the list to avoid unexpected behaviour
- if (
- (await NocoCache.getList(CacheScope.MAP_VIEW_COLUMN, [column.fk_view_id]))
- ?.length
- )
+ const { list } = await NocoCache.getList(CacheScope.MAP_VIEW_COLUMN, [
+ column.fk_view_id,
+ ]);
+ if (list?.length)
await NocoCache.appendToList(
CacheScope.MAP_VIEW_COLUMN,
[column.fk_view_id],
@@ -84,8 +84,12 @@ export default class MapViewColumn {
viewId: string,
ncMeta = Noco.ncMeta,
): Promise {
- let views = await NocoCache.getList(CacheScope.MAP_VIEW_COLUMN, [viewId]);
- if (!views.length) {
+ const cachedList = await NocoCache.getList(CacheScope.MAP_VIEW_COLUMN, [
+ viewId,
+ ]);
+ let { list: views } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !views.length) {
views = await ncMeta.metaList2(null, null, MetaTable.MAP_VIEW_COLUMNS, {
condition: {
fk_view_id: viewId,
diff --git a/packages/nocodb-nest/src/models/Model.ts b/packages/nocodb-nest/src/models/Model.ts
index 6a1e78bd9a..abb6ec5268 100644
--- a/packages/nocodb-nest/src/models/Model.ts
+++ b/packages/nocodb-nest/src/models/Model.ts
@@ -161,13 +161,10 @@ export default class Model implements TableType {
},
ncMeta = Noco.ncMeta,
): Promise {
- let modelList = [];
- if (base_id) {
- await NocoCache.getList(CacheScope.MODEL, [project_id, base_id]);
- } else {
- await NocoCache.getList(CacheScope.MODEL, [project_id]);
- }
- if (!modelList.length) {
+ const cachedList = await NocoCache.getList(CacheScope.MODEL, [project_id]);
+ let { list: modelList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !modelList.length) {
modelList = await ncMeta.metaList2(
project_id,
base_id,
@@ -184,15 +181,7 @@ export default class Model implements TableType {
model.meta = parseMetaProp(model);
}
- if (base_id) {
- await NocoCache.setList(
- CacheScope.MODEL,
- [project_id, base_id],
- modelList,
- );
- } else {
- await NocoCache.setList(CacheScope.MODEL, [project_id], modelList);
- }
+ await NocoCache.setList(CacheScope.MODEL, [project_id], modelList);
}
modelList.sort(
(a, b) =>
@@ -212,11 +201,13 @@ export default class Model implements TableType {
},
ncMeta = Noco.ncMeta,
): Promise {
- let modelList = await NocoCache.getList(CacheScope.MODEL, [
+ const cachedList = await NocoCache.getList(CacheScope.MODEL, [
project_id,
db_alias,
]);
- if (!modelList.length) {
+ let { list: modelList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !modelList.length) {
modelList = await ncMeta.metaList2(
project_id,
db_alias,
diff --git a/packages/nocodb-nest/src/models/ModelRoleVisibility.ts b/packages/nocodb-nest/src/models/ModelRoleVisibility.ts
index acf942998d..7cea0a4ad6 100644
--- a/packages/nocodb-nest/src/models/ModelRoleVisibility.ts
+++ b/packages/nocodb-nest/src/models/ModelRoleVisibility.ts
@@ -24,10 +24,13 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType {
}
static async list(projectId): Promise {
- let data = await NocoCache.getList(CacheScope.MODEL_ROLE_VISIBILITY, [
- projectId,
- ]);
- if (!data.length) {
+ const cachedList = await NocoCache.getList(
+ CacheScope.MODEL_ROLE_VISIBILITY,
+ [projectId],
+ );
+ let { list: data } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !data.length) {
data = await Noco.ncMeta.metaList2(
projectId,
null,
diff --git a/packages/nocodb-nest/src/models/Plugin.ts b/packages/nocodb-nest/src/models/Plugin.ts
index 234400f942..ac4236ce37 100644
--- a/packages/nocodb-nest/src/models/Plugin.ts
+++ b/packages/nocodb-nest/src/models/Plugin.ts
@@ -43,8 +43,10 @@ export default class Plugin implements PluginType {
}
static async list(ncMeta = Noco.ncMeta) {
- let pluginList = await NocoCache.getList(CacheScope.PLUGIN, []);
- if (!pluginList.length) {
+ const cachedList = await NocoCache.getList(CacheScope.PLUGIN, []);
+ let { list: pluginList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !pluginList.length) {
pluginList = await ncMeta.metaList2(null, null, MetaTable.PLUGIN);
await NocoCache.setList(CacheScope.PLUGIN, [], pluginList);
}
diff --git a/packages/nocodb-nest/src/models/Project.ts b/packages/nocodb-nest/src/models/Project.ts
index 87d0e6fa7e..9a3394efd7 100644
--- a/packages/nocodb-nest/src/models/Project.ts
+++ b/packages/nocodb-nest/src/models/Project.ts
@@ -79,8 +79,10 @@ export default class Project implements ProjectType {
ncMeta = Noco.ncMeta,
): Promise {
// todo: pagination
- let projectList = await NocoCache.getList(CacheScope.PROJECT, []);
- if (!projectList.length) {
+ const cachedList = await NocoCache.getList(CacheScope.PROJECT, []);
+ let { list: projectList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !projectList.length) {
projectList = await ncMeta.metaList2(null, null, MetaTable.PROJECT, {
xcCondition: {
_or: [
diff --git a/packages/nocodb-nest/src/models/ProjectUser.ts b/packages/nocodb-nest/src/models/ProjectUser.ts
index 123d8be3c6..f3d8897541 100644
--- a/packages/nocodb-nest/src/models/ProjectUser.ts
+++ b/packages/nocodb-nest/src/models/ProjectUser.ts
@@ -187,10 +187,12 @@ export default class ProjectUser {
}
// remove project from user project list cache
- let cachedProjectList = await NocoCache.getList(CacheScope.USER_PROJECT, [
+ const cachedList = await NocoCache.getList(CacheScope.USER_PROJECT, [
userId,
]);
- if (cachedProjectList?.length) {
+ let { list: cachedProjectList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && cachedProjectList?.length) {
cachedProjectList = cachedProjectList.filter((p) => p.id !== projectId);
await NocoCache.setList(
CacheScope.USER_PROJECT,
@@ -221,11 +223,13 @@ export default class ProjectUser {
ncMeta = Noco.ncMeta,
): Promise {
// todo: pagination
- let projectList = await NocoCache.getList(CacheScope.USER_PROJECT, [
+ const cachedList = await NocoCache.getList(CacheScope.USER_PROJECT, [
userId,
]);
+ let { list: projectList } = cachedList;
+ const { isNoneList } = cachedList;
- if (projectList.length) {
+ if (!isNoneList && projectList.length) {
return projectList;
}
diff --git a/packages/nocodb-nest/src/models/SelectOption.ts b/packages/nocodb-nest/src/models/SelectOption.ts
index fdfaa24891..777d252b00 100644
--- a/packages/nocodb-nest/src/models/SelectOption.ts
+++ b/packages/nocodb-nest/src/models/SelectOption.ts
@@ -69,10 +69,12 @@ export default class SelectOption implements SelectOptionType {
}
public static async read(fk_column_id: string, ncMeta = Noco.ncMeta) {
- let options = await NocoCache.getList(CacheScope.COL_SELECT_OPTION, [
+ const cachedList = await NocoCache.getList(CacheScope.COL_SELECT_OPTION, [
fk_column_id,
]);
- if (!options.length) {
+ let { list: options } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !options.length) {
options = await ncMeta.metaList2(
null, //,
null, //model.db_alias,
diff --git a/packages/nocodb-nest/src/models/Sort.ts b/packages/nocodb-nest/src/models/Sort.ts
index c6c7de3dac..7436da4021 100644
--- a/packages/nocodb-nest/src/models/Sort.ts
+++ b/packages/nocodb-nest/src/models/Sort.ts
@@ -114,8 +114,10 @@ export default class Sort {
ncMeta = Noco.ncMeta,
): Promise {
if (!viewId) return null;
- let sortList = await NocoCache.getList(CacheScope.SORT, [viewId]);
- if (!sortList.length) {
+ const cachedList = await NocoCache.getList(CacheScope.SORT, [viewId]);
+ let { list: sortList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !sortList.length) {
sortList = await ncMeta.metaList2(null, null, MetaTable.SORT, {
condition: { fk_view_id: viewId },
orderBy: {
diff --git a/packages/nocodb-nest/src/models/View.ts b/packages/nocodb-nest/src/models/View.ts
index cca7b596ab..86abcae743 100644
--- a/packages/nocodb-nest/src/models/View.ts
+++ b/packages/nocodb-nest/src/models/View.ts
@@ -205,8 +205,10 @@ export default class View implements ViewType {
}
public static async list(modelId: string, ncMeta = Noco.ncMeta) {
- let viewsList = await NocoCache.getList(CacheScope.VIEW, [modelId]);
- if (!viewsList.length) {
+ const cachedList = await NocoCache.getList(CacheScope.VIEW, [modelId]);
+ let { list: viewsList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !viewsList.length) {
viewsList = await ncMeta.metaList2(null, null, MetaTable.VIEWS, {
condition: {
fk_model_id: modelId,
@@ -1123,8 +1125,10 @@ export default class View implements ViewType {
);
// get existing cache
- const dataList = await NocoCache.getList(scope, [viewId]);
- if (dataList?.length) {
+ const cachedList = await NocoCache.getList(scope, [viewId]);
+ const { list: dataList } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && dataList?.length) {
for (const o of dataList) {
if (!ignoreColdIds?.length || !ignoreColdIds.includes(o.fk_column_id)) {
// set data
@@ -1209,7 +1213,9 @@ export default class View implements ViewType {
}
// get existing cache
- const dataList = await NocoCache.getList(scope, [viewId]);
+ const cachedList = await NocoCache.getList(scope, [viewId]);
+ const { list: dataList } = cachedList;
+ const { isNoneList } = cachedList;
const colsEssentialForView =
view.type === ViewTypes.MAP
@@ -1218,7 +1224,7 @@ export default class View implements ViewType {
const mergedIgnoreColdIds = [...ignoreColdIds, ...colsEssentialForView];
- if (dataList?.length) {
+ if (!isNoneList && dataList?.length) {
for (const o of dataList) {
if (
!mergedIgnoreColdIds?.length ||
@@ -1257,8 +1263,10 @@ export default class View implements ViewType {
}
static async shareViewList(tableId, ncMeta = Noco.ncMeta) {
- let sharedViews = await NocoCache.getList(CacheScope.VIEW, [tableId]);
- if (!sharedViews.length) {
+ const cachedList = await NocoCache.getList(CacheScope.VIEW, [tableId]);
+ let { list: sharedViews } = cachedList;
+ const { isNoneList } = cachedList;
+ if (!isNoneList && !sharedViews.length) {
sharedViews = await ncMeta.metaList2(null, null, MetaTable.VIEWS, {
xcCondition: {
fk_model_id: {