Browse Source

feat(nocodb): add isNoneList

pull/5430/head
Wing-Kam Wong 2 years ago
parent
commit
e8dda4426d
  1. 3
      packages/nocodb/src/lib/models/Base.ts
  2. 18
      packages/nocodb/src/lib/models/Column.ts
  3. 3
      packages/nocodb/src/lib/models/FormViewColumn.ts
  4. 3
      packages/nocodb/src/lib/models/GalleryViewColumn.ts
  5. 3
      packages/nocodb/src/lib/models/GridViewColumn.ts
  6. 3
      packages/nocodb/src/lib/models/Hook.ts
  7. 9
      packages/nocodb/src/lib/models/HookFilter.ts
  8. 3
      packages/nocodb/src/lib/models/KanbanViewColumn.ts
  9. 3
      packages/nocodb/src/lib/models/MapViewColumn.ts
  10. 7
      packages/nocodb/src/lib/models/Model.ts
  11. 3
      packages/nocodb/src/lib/models/Plugin.ts
  12. 3
      packages/nocodb/src/lib/models/Project.ts
  13. 6
      packages/nocodb/src/lib/models/ProjectUser.ts
  14. 3
      packages/nocodb/src/lib/models/SelectOption.ts
  15. 12
      packages/nocodb/src/lib/models/View.ts

3
packages/nocodb/src/lib/models/Base.ts

@ -154,7 +154,8 @@ export default class Base implements BaseType {
args.projectId,
]);
let { list: baseDataList } = cachedList;
if (!baseDataList.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !baseDataList.length) {
baseDataList = await ncMeta.metaList2(
args.projectId,
null,

18
packages/nocodb/src/lib/models/Column.ts

@ -478,7 +478,8 @@ export default class Column<T = any> implements ColumnType {
fk_model_id,
]);
let { list: columnsList } = cachedList;
if (!columnsList.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !columnsList.length) {
columnsList = await ncMeta.metaList2(null, null, MetaTable.COLUMNS, {
condition: {
fk_model_id,
@ -632,7 +633,8 @@ export default class Column<T = any> implements ColumnType {
{
const cachedList = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]);
let { list: lookups } = cachedList;
if (!lookups.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !lookups.length) {
lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, {
condition: { fk_lookup_column_id: id },
});
@ -646,7 +648,8 @@ export default class Column<T = any> implements ColumnType {
{
const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]);
let { list: rollups } = cachedList;
if (!rollups.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !rollups.length) {
rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, {
condition: { fk_rollup_column_id: id },
});
@ -661,7 +664,8 @@ export default class Column<T = any> implements ColumnType {
col.fk_model_id,
]);
let { list: formulaColumns } = cachedList;
if (!formulaColumns.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !formulaColumns.length) {
formulaColumns = await ncMeta.metaList2(null, null, MetaTable.COLUMNS, {
condition: {
fk_model_id: col.fk_model_id,
@ -692,7 +696,8 @@ export default class Column<T = any> implements ColumnType {
// get lookup columns using relation and delete
const cachedList = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]);
let { list: lookups } = cachedList;
if (!lookups.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !lookups.length) {
lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, {
condition: { fk_relation_column_id: id },
});
@ -706,7 +711,8 @@ export default class Column<T = any> implements ColumnType {
// get rollup columns using relation and delete
const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]);
let { list: rollups } = cachedList;
if (!rollups.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !rollups.length) {
rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, {
condition: { fk_relation_column_id: id },
});

3
packages/nocodb/src/lib/models/FormViewColumn.ts

@ -121,7 +121,8 @@ export default class FormViewColumn implements FormColumnType {
viewId,
]);
let { list: viewColumns } = cachedList;
if (!viewColumns.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !viewColumns.length) {
viewColumns = await ncMeta.metaList2(
null,
null,

3
packages/nocodb/src/lib/models/GalleryViewColumn.ts

@ -101,7 +101,8 @@ export default class GalleryViewColumn {
viewId,
]);
let { list: views } = cachedList;
if (!views.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !views.length) {
views = await ncMeta.metaList2(
null,
null,

3
packages/nocodb/src/lib/models/GridViewColumn.ts

@ -28,7 +28,8 @@ export default class GridViewColumn implements GridColumnType {
viewId,
]);
let { list: views } = cachedList;
if (!views.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !views.length) {
views = await ncMeta.metaList2(null, null, MetaTable.GRID_VIEW_COLUMNS, {
condition: {
fk_view_id: viewId,

3
packages/nocodb/src/lib/models/Hook.ts

@ -89,7 +89,8 @@ export default class Hook implements HookType {
param.fk_model_id,
]);
let { list: hooks } = cachedList;
if (!hooks.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !hooks.length) {
hooks = await ncMeta.metaList(null, null, MetaTable.HOOKS, {
condition: {
fk_model_id: param.fk_model_id,

9
packages/nocodb/src/lib/models/HookFilter.ts

@ -209,7 +209,8 @@ export default class Filter {
this.id,
]);
let { list: childFilters } = cachedList;
if (!childFilters.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !childFilters.length) {
childFilters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: {
fk_parent_id: this.id,
@ -246,7 +247,8 @@ export default class Filter {
): Promise<FilterType> {
const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]);
let { list: filters } = cachedList;
if (!filters.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !filters.length) {
filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: { fk_view_id: viewId },
});
@ -331,7 +333,8 @@ export default class Filter {
) {
const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]);
let { list: filterObjs } = cachedList;
if (!filterObjs.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !filterObjs.length) {
filterObjs = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, {
condition: { fk_view_id: viewId },
});

3
packages/nocodb/src/lib/models/KanbanViewColumn.ts

@ -89,7 +89,8 @@ export default class KanbanViewColumn implements KanbanColumnType {
viewId,
]);
let { list: views } = cachedList;
if (!views.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !views.length) {
views = await ncMeta.metaList2(
null,
null,

3
packages/nocodb/src/lib/models/MapViewColumn.ts

@ -88,7 +88,8 @@ export default class MapViewColumn {
viewId,
]);
let { list: views } = cachedList;
if (!views.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !views.length) {
views = await ncMeta.metaList2(null, null, MetaTable.MAP_VIEW_COLUMNS, {
condition: {
fk_view_id: viewId,

7
packages/nocodb/src/lib/models/Model.ts

@ -162,8 +162,8 @@ export default class Model implements TableType {
): Promise<Model[]> {
const cachedList = await NocoCache.getList(CacheScope.MODEL, [project_id]);
let { list: modelList } = cachedList;
if (!modelList.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !modelList.length) {
modelList = await ncMeta.metaList2(
project_id,
base_id,
@ -205,7 +205,8 @@ export default class Model implements TableType {
db_alias,
]);
let { list: modelList } = cachedList;
if (!modelList.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !modelList.length) {
modelList = await ncMeta.metaList2(
project_id,
db_alias,

3
packages/nocodb/src/lib/models/Plugin.ts

@ -45,7 +45,8 @@ export default class Plugin implements PluginType {
static async list(ncMeta = Noco.ncMeta) {
const cachedList = await NocoCache.getList(CacheScope.PLUGIN, []);
let { list: pluginList } = cachedList;
if (!pluginList.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !pluginList.length) {
pluginList = await ncMeta.metaList2(null, null, MetaTable.PLUGIN);
await NocoCache.setList(CacheScope.PLUGIN, [], pluginList);
}

3
packages/nocodb/src/lib/models/Project.ts

@ -81,7 +81,8 @@ export default class Project implements ProjectType {
// todo: pagination
const cachedList = await NocoCache.getList(CacheScope.PROJECT, []);
let { list: projectList } = cachedList;
if (!projectList.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !projectList.length) {
projectList = await ncMeta.metaList2(null, null, MetaTable.PROJECT, {
xcCondition: {
_or: [

6
packages/nocodb/src/lib/models/ProjectUser.ts

@ -191,7 +191,8 @@ export default class ProjectUser {
userId,
]);
let { list: cachedProjectList } = cachedList;
if (cachedProjectList?.length) {
const { isNoneList } = cachedList;
if (!isNoneList && cachedProjectList?.length) {
cachedProjectList = cachedProjectList.filter((p) => p.id !== projectId);
await NocoCache.setList(
CacheScope.USER_PROJECT,
@ -226,8 +227,9 @@ export default class ProjectUser {
userId,
]);
let { list: projectList } = cachedList;
const { isNoneList } = cachedList;
if (projectList.length) {
if (!isNoneList && projectList.length) {
return projectList;
}

3
packages/nocodb/src/lib/models/SelectOption.ts

@ -73,7 +73,8 @@ export default class SelectOption implements SelectOptionType {
fk_column_id,
]);
let { list: options } = cachedList;
if (!options.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !options.length) {
options = await ncMeta.metaList2(
null, //,
null, //model.db_alias,

12
packages/nocodb/src/lib/models/View.ts

@ -207,7 +207,8 @@ export default class View implements ViewType {
public static async list(modelId: string, ncMeta = Noco.ncMeta) {
const cachedList = await NocoCache.getList(CacheScope.VIEW, [modelId]);
let { list: viewsList } = cachedList;
if (!viewsList.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !viewsList.length) {
viewsList = await ncMeta.metaList2(null, null, MetaTable.VIEWS, {
condition: {
fk_model_id: modelId,
@ -1126,7 +1127,8 @@ export default class View implements ViewType {
// get existing cache
const cachedList = await NocoCache.getList(scope, [viewId]);
const { list: dataList } = cachedList;
if (dataList?.length) {
const { isNoneList } = cachedList;
if (!isNoneList && dataList?.length) {
for (const o of dataList) {
if (!ignoreColdIds?.length || !ignoreColdIds.includes(o.fk_column_id)) {
// set data
@ -1213,6 +1215,7 @@ export default class View implements ViewType {
// get existing cache
const cachedList = await NocoCache.getList(scope, [viewId]);
const { list: dataList } = cachedList;
const { isNoneList } = cachedList;
const colsEssentialForView =
view.type === ViewTypes.MAP
@ -1221,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 ||
@ -1262,7 +1265,8 @@ export default class View implements ViewType {
static async shareViewList(tableId, ncMeta = Noco.ncMeta) {
const cachedList = await NocoCache.getList(CacheScope.VIEW, [tableId]);
let { list: sharedViews } = cachedList;
if (!sharedViews.length) {
const { isNoneList } = cachedList;
if (!isNoneList && !sharedViews.length) {
sharedViews = await ncMeta.metaList2(null, null, MetaTable.VIEWS, {
xcCondition: {
fk_model_id: {

Loading…
Cancel
Save