|
|
@ -474,8 +474,12 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
): Promise<Column[]> { |
|
|
|
): Promise<Column[]> { |
|
|
|
let columnsList = await NocoCache.getList(CacheScope.COLUMN, [fk_model_id]); |
|
|
|
const cachedList = await NocoCache.getList(CacheScope.COLUMN, [ |
|
|
|
if (!columnsList.length) { |
|
|
|
fk_model_id, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
let { list: columnsList } = cachedList; |
|
|
|
|
|
|
|
const { isNoneList } = cachedList; |
|
|
|
|
|
|
|
if (!isNoneList && !columnsList.length) { |
|
|
|
columnsList = await ncMeta.metaList2(null, null, MetaTable.COLUMNS, { |
|
|
|
columnsList = await ncMeta.metaList2(null, null, MetaTable.COLUMNS, { |
|
|
|
condition: { |
|
|
|
condition: { |
|
|
|
fk_model_id, |
|
|
|
fk_model_id, |
|
|
@ -627,8 +631,10 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
|
|
|
|
|
|
|
|
// get lookup columns and delete
|
|
|
|
// get lookup columns and delete
|
|
|
|
{ |
|
|
|
{ |
|
|
|
let lookups = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]); |
|
|
|
const cachedList = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]); |
|
|
|
if (!lookups.length) { |
|
|
|
let { list: lookups } = cachedList; |
|
|
|
|
|
|
|
const { isNoneList } = cachedList; |
|
|
|
|
|
|
|
if (!isNoneList && !lookups.length) { |
|
|
|
lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, { |
|
|
|
lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, { |
|
|
|
condition: { fk_lookup_column_id: id }, |
|
|
|
condition: { fk_lookup_column_id: id }, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -640,8 +646,10 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
|
|
|
|
|
|
|
|
// get rollup column and delete
|
|
|
|
// get rollup column and delete
|
|
|
|
{ |
|
|
|
{ |
|
|
|
let rollups = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]); |
|
|
|
const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]); |
|
|
|
if (!rollups.length) { |
|
|
|
let { list: rollups } = cachedList; |
|
|
|
|
|
|
|
const { isNoneList } = cachedList; |
|
|
|
|
|
|
|
if (!isNoneList && !rollups.length) { |
|
|
|
rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, { |
|
|
|
rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, { |
|
|
|
condition: { fk_rollup_column_id: id }, |
|
|
|
condition: { fk_rollup_column_id: id }, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -652,10 +660,12 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
let formulaColumns = await NocoCache.getList(CacheScope.COLUMN, [ |
|
|
|
const cachedList = await NocoCache.getList(CacheScope.COLUMN, [ |
|
|
|
col.fk_model_id, |
|
|
|
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, { |
|
|
|
formulaColumns = await ncMeta.metaList2(null, null, MetaTable.COLUMNS, { |
|
|
|
condition: { |
|
|
|
condition: { |
|
|
|
fk_model_id: col.fk_model_id, |
|
|
|
fk_model_id: col.fk_model_id, |
|
|
@ -682,9 +692,12 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
|
|
|
|
|
|
|
|
// if relation column check lookup and rollup and delete
|
|
|
|
// if relation column check lookup and rollup and delete
|
|
|
|
if (col.uidt === UITypes.LinkToAnotherRecord) { |
|
|
|
if (col.uidt === UITypes.LinkToAnotherRecord) { |
|
|
|
|
|
|
|
{ |
|
|
|
// get lookup columns using relation and delete
|
|
|
|
// get lookup columns using relation and delete
|
|
|
|
let lookups = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]); |
|
|
|
const cachedList = await NocoCache.getList(CacheScope.COL_LOOKUP, [id]); |
|
|
|
if (!lookups.length) { |
|
|
|
let { list: lookups } = cachedList; |
|
|
|
|
|
|
|
const { isNoneList } = cachedList; |
|
|
|
|
|
|
|
if (!isNoneList && !lookups.length) { |
|
|
|
lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, { |
|
|
|
lookups = await ncMeta.metaList2(null, null, MetaTable.COL_LOOKUP, { |
|
|
|
condition: { fk_relation_column_id: id }, |
|
|
|
condition: { fk_relation_column_id: id }, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -692,10 +705,14 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
for (const lookup of lookups) { |
|
|
|
for (const lookup of lookups) { |
|
|
|
await Column.delete(lookup.fk_column_id, ncMeta); |
|
|
|
await Column.delete(lookup.fk_column_id, ncMeta); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
// get rollup columns using relation and delete
|
|
|
|
// get rollup columns using relation and delete
|
|
|
|
let rollups = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]); |
|
|
|
const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]); |
|
|
|
if (!rollups.length) { |
|
|
|
let { list: rollups } = cachedList; |
|
|
|
|
|
|
|
const { isNoneList } = cachedList; |
|
|
|
|
|
|
|
if (!isNoneList && !rollups.length) { |
|
|
|
rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, { |
|
|
|
rollups = await ncMeta.metaList2(null, null, MetaTable.COL_ROLLUP, { |
|
|
|
condition: { fk_relation_column_id: id }, |
|
|
|
condition: { fk_relation_column_id: id }, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -704,11 +721,14 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
await Column.delete(rollup.fk_column_id, ncMeta); |
|
|
|
await Column.delete(rollup.fk_column_id, ncMeta); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// delete sorts
|
|
|
|
// delete sorts
|
|
|
|
{ |
|
|
|
{ |
|
|
|
let sorts = await NocoCache.getList(CacheScope.SORT, [id]); |
|
|
|
const cachedList = await NocoCache.getList(CacheScope.SORT, [id]); |
|
|
|
if (!sorts.length) { |
|
|
|
let { list: sorts } = cachedList; |
|
|
|
|
|
|
|
const { isNoneList } = cachedList; |
|
|
|
|
|
|
|
if (!isNoneList && !sorts.length) { |
|
|
|
sorts = await ncMeta.metaList2(null, null, MetaTable.SORT, { |
|
|
|
sorts = await ncMeta.metaList2(null, null, MetaTable.SORT, { |
|
|
|
condition: { |
|
|
|
condition: { |
|
|
|
fk_column_id: id, |
|
|
|
fk_column_id: id, |
|
|
@ -721,8 +741,10 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
} |
|
|
|
} |
|
|
|
// delete filters
|
|
|
|
// delete filters
|
|
|
|
{ |
|
|
|
{ |
|
|
|
let filters = await NocoCache.getList(CacheScope.FILTER_EXP, [id]); |
|
|
|
const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [id]); |
|
|
|
if (!filters.length) { |
|
|
|
let { list: filters } = cachedList; |
|
|
|
|
|
|
|
const { isNoneList } = cachedList; |
|
|
|
|
|
|
|
if (!isNoneList && !filters.length) { |
|
|
|
filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, { |
|
|
|
filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, { |
|
|
|
condition: { |
|
|
|
condition: { |
|
|
|
fk_column_id: id, |
|
|
|
fk_column_id: id, |
|
|
|