Browse Source

refactor(nocodb): adopt getList new format in MapViewColumn.ts

pull/5430/head
Wing-Kam Wong 2 years ago
parent
commit
1697c75f41
  1. 12
      packages/nocodb/src/lib/models/MapViewColumn.ts

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

@ -67,7 +67,9 @@ export default class MapViewColumn {
await NocoCache.set(`${CacheScope.MAP_VIEW_COLUMN}:${fk_column_id}`, id); 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 cache is not present skip pushing it into the list to avoid unexpected behaviour
const { list } = await NocoCache.getList(CacheScope.MAP_VIEW_COLUMN, [column.fk_view_id]); const { list } = await NocoCache.getList(CacheScope.MAP_VIEW_COLUMN, [
column.fk_view_id,
]);
if (list?.length) if (list?.length)
await NocoCache.appendToList( await NocoCache.appendToList(
CacheScope.MAP_VIEW_COLUMN, CacheScope.MAP_VIEW_COLUMN,
@ -82,8 +84,12 @@ export default class MapViewColumn {
viewId: string, viewId: string,
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
): Promise<MapViewColumn[]> { ): Promise<MapViewColumn[]> {
let views = await NocoCache.getList(CacheScope.MAP_VIEW_COLUMN, [viewId]); const cachedList = await NocoCache.getList(CacheScope.MAP_VIEW_COLUMN, [
if (!views.length) { viewId,
]);
let { list: views } = cachedList;
const { isEmptyList } = cachedList;
if (!isEmptyList && !views.length) {
views = await ncMeta.metaList2(null, null, MetaTable.MAP_VIEW_COLUMNS, { views = await ncMeta.metaList2(null, null, MetaTable.MAP_VIEW_COLUMNS, {
condition: { condition: {
fk_view_id: viewId, fk_view_id: viewId,

Loading…
Cancel
Save