|
|
@ -57,7 +57,7 @@ export default class Model implements TableType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
fk_model_id: this.id, |
|
|
|
fk_model_id: this.id, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta, |
|
|
|
ncMeta |
|
|
|
); |
|
|
|
); |
|
|
|
return this.columns; |
|
|
|
return this.columns; |
|
|
|
} |
|
|
|
} |
|
|
@ -94,7 +94,7 @@ export default class Model implements TableType { |
|
|
|
mm?: BoolType; |
|
|
|
mm?: BoolType; |
|
|
|
type?: ModelTypes; |
|
|
|
type?: ModelTypes; |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
) { |
|
|
|
) { |
|
|
|
const insertObj = extractProps(model, [ |
|
|
|
const insertObj = extractProps(model, [ |
|
|
|
'table_name', |
|
|
|
'table_name', |
|
|
@ -113,7 +113,7 @@ export default class Model implements TableType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
project_id: projectId, |
|
|
|
project_id: projectId, |
|
|
|
base_id: baseId, |
|
|
|
base_id: baseId, |
|
|
|
}, |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -125,13 +125,13 @@ export default class Model implements TableType { |
|
|
|
projectId, |
|
|
|
projectId, |
|
|
|
baseId, |
|
|
|
baseId, |
|
|
|
MetaTable.MODELS, |
|
|
|
MetaTable.MODELS, |
|
|
|
insertObj, |
|
|
|
insertObj |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await NocoCache.appendToList( |
|
|
|
await NocoCache.appendToList( |
|
|
|
CacheScope.MODEL, |
|
|
|
CacheScope.MODEL, |
|
|
|
[projectId], |
|
|
|
[projectId], |
|
|
|
`${CacheScope.MODEL}:${id}`, |
|
|
|
`${CacheScope.MODEL}:${id}` |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const view = await View.insert( |
|
|
|
const view = await View.insert( |
|
|
@ -141,7 +141,7 @@ export default class Model implements TableType { |
|
|
|
is_default: true, |
|
|
|
is_default: true, |
|
|
|
type: ViewTypes.GRID, |
|
|
|
type: ViewTypes.GRID, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta, |
|
|
|
ncMeta |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
for (const column of model?.columns || []) { |
|
|
|
for (const column of model?.columns || []) { |
|
|
@ -159,7 +159,7 @@ export default class Model implements TableType { |
|
|
|
project_id: string; |
|
|
|
project_id: string; |
|
|
|
base_id: string; |
|
|
|
base_id: string; |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
): Promise<Model[]> { |
|
|
|
): Promise<Model[]> { |
|
|
|
let modelList = []; |
|
|
|
let modelList = []; |
|
|
|
if (base_id) { |
|
|
|
if (base_id) { |
|
|
@ -176,7 +176,7 @@ export default class Model implements TableType { |
|
|
|
orderBy: { |
|
|
|
orderBy: { |
|
|
|
order: 'asc', |
|
|
|
order: 'asc', |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// parse meta of each model
|
|
|
|
// parse meta of each model
|
|
|
@ -188,7 +188,7 @@ export default class Model implements TableType { |
|
|
|
await NocoCache.setList( |
|
|
|
await NocoCache.setList( |
|
|
|
CacheScope.MODEL, |
|
|
|
CacheScope.MODEL, |
|
|
|
[project_id, base_id], |
|
|
|
[project_id, base_id], |
|
|
|
modelList, |
|
|
|
modelList |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
await NocoCache.setList(CacheScope.MODEL, [project_id], modelList); |
|
|
|
await NocoCache.setList(CacheScope.MODEL, [project_id], modelList); |
|
|
@ -197,7 +197,7 @@ export default class Model implements TableType { |
|
|
|
modelList.sort( |
|
|
|
modelList.sort( |
|
|
|
(a, b) => |
|
|
|
(a, b) => |
|
|
|
(a.order != null ? a.order : Infinity) - |
|
|
|
(a.order != null ? a.order : Infinity) - |
|
|
|
(b.order != null ? b.order : Infinity), |
|
|
|
(b.order != null ? b.order : Infinity) |
|
|
|
); |
|
|
|
); |
|
|
|
return modelList.map((m) => new Model(m)); |
|
|
|
return modelList.map((m) => new Model(m)); |
|
|
|
} |
|
|
|
} |
|
|
@ -210,7 +210,7 @@ export default class Model implements TableType { |
|
|
|
project_id: string; |
|
|
|
project_id: string; |
|
|
|
db_alias: string; |
|
|
|
db_alias: string; |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
): Promise<Model[]> { |
|
|
|
): Promise<Model[]> { |
|
|
|
let modelList = await NocoCache.getList(CacheScope.MODEL, [ |
|
|
|
let modelList = await NocoCache.getList(CacheScope.MODEL, [ |
|
|
|
project_id, |
|
|
|
project_id, |
|
|
@ -220,7 +220,7 @@ export default class Model implements TableType { |
|
|
|
modelList = await ncMeta.metaList2( |
|
|
|
modelList = await ncMeta.metaList2( |
|
|
|
project_id, |
|
|
|
project_id, |
|
|
|
db_alias, |
|
|
|
db_alias, |
|
|
|
MetaTable.MODELS, |
|
|
|
MetaTable.MODELS |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// parse meta of each model
|
|
|
|
// parse meta of each model
|
|
|
@ -244,7 +244,7 @@ export default class Model implements TableType { |
|
|
|
id && |
|
|
|
id && |
|
|
|
(await NocoCache.get( |
|
|
|
(await NocoCache.get( |
|
|
|
`${CacheScope.MODEL}:${id}`, |
|
|
|
`${CacheScope.MODEL}:${id}`, |
|
|
|
CacheGetType.TYPE_OBJECT, |
|
|
|
CacheGetType.TYPE_OBJECT |
|
|
|
)); |
|
|
|
)); |
|
|
|
if (!modelData) { |
|
|
|
if (!modelData) { |
|
|
|
modelData = await ncMeta.metaGet2(null, null, MetaTable.MODELS, id); |
|
|
|
modelData = await ncMeta.metaGet2(null, null, MetaTable.MODELS, id); |
|
|
@ -267,14 +267,14 @@ export default class Model implements TableType { |
|
|
|
| { |
|
|
|
| { |
|
|
|
id?: string; |
|
|
|
id?: string; |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
): Promise<Model> { |
|
|
|
): Promise<Model> { |
|
|
|
const k = 'id' in args ? args?.id : args; |
|
|
|
const k = 'id' in args ? args?.id : args; |
|
|
|
let modelData = |
|
|
|
let modelData = |
|
|
|
k && |
|
|
|
k && |
|
|
|
(await NocoCache.get( |
|
|
|
(await NocoCache.get( |
|
|
|
`${CacheScope.MODEL}:${k}`, |
|
|
|
`${CacheScope.MODEL}:${k}`, |
|
|
|
CacheGetType.TYPE_OBJECT, |
|
|
|
CacheGetType.TYPE_OBJECT |
|
|
|
)); |
|
|
|
)); |
|
|
|
if (!modelData) { |
|
|
|
if (!modelData) { |
|
|
|
modelData = await ncMeta.metaGet2(null, null, MetaTable.MODELS, k); |
|
|
|
modelData = await ncMeta.metaGet2(null, null, MetaTable.MODELS, k); |
|
|
@ -295,13 +295,13 @@ export default class Model implements TableType { |
|
|
|
table_name?: string; |
|
|
|
table_name?: string; |
|
|
|
id?: string; |
|
|
|
id?: string; |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
): Promise<Model> { |
|
|
|
): Promise<Model> { |
|
|
|
let modelData = |
|
|
|
let modelData = |
|
|
|
id && |
|
|
|
id && |
|
|
|
(await NocoCache.get( |
|
|
|
(await NocoCache.get( |
|
|
|
`${CacheScope.MODEL}:${id}`, |
|
|
|
`${CacheScope.MODEL}:${id}`, |
|
|
|
CacheGetType.TYPE_OBJECT, |
|
|
|
CacheGetType.TYPE_OBJECT |
|
|
|
)); |
|
|
|
)); |
|
|
|
if (!modelData) { |
|
|
|
if (!modelData) { |
|
|
|
modelData = await ncMeta.metaGet2( |
|
|
|
modelData = await ncMeta.metaGet2( |
|
|
@ -310,7 +310,7 @@ export default class Model implements TableType { |
|
|
|
MetaTable.MODELS, |
|
|
|
MetaTable.MODELS, |
|
|
|
id || { |
|
|
|
id || { |
|
|
|
table_name, |
|
|
|
table_name, |
|
|
|
}, |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
modelData.meta = parseMetaProp(modelData); |
|
|
|
modelData.meta = parseMetaProp(modelData); |
|
|
|
await NocoCache.set(`${CacheScope.MODEL}:${modelData.id}`, modelData); |
|
|
|
await NocoCache.set(`${CacheScope.MODEL}:${modelData.id}`, modelData); |
|
|
@ -336,7 +336,7 @@ export default class Model implements TableType { |
|
|
|
dbDriver: XKnex; |
|
|
|
dbDriver: XKnex; |
|
|
|
model?: Model; |
|
|
|
model?: Model; |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
): Promise<BaseModelSqlv2> { |
|
|
|
): Promise<BaseModelSqlv2> { |
|
|
|
const model = args?.model || (await this.get(args.id, ncMeta)); |
|
|
|
const model = args?.model || (await this.get(args.id, ncMeta)); |
|
|
|
|
|
|
|
|
|
|
@ -388,7 +388,7 @@ export default class Model implements TableType { |
|
|
|
await NocoCache.deepDel( |
|
|
|
await NocoCache.deepDel( |
|
|
|
cacheScopeName, |
|
|
|
cacheScopeName, |
|
|
|
`${cacheScopeName}:${col.id}`, |
|
|
|
`${cacheScopeName}:${col.id}`, |
|
|
|
CacheDelDirection.CHILD_TO_PARENT, |
|
|
|
CacheDelDirection.CHILD_TO_PARENT |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -402,14 +402,14 @@ export default class Model implements TableType { |
|
|
|
condition: { |
|
|
|
condition: { |
|
|
|
fk_related_model_id: this.id, |
|
|
|
fk_related_model_id: this.id, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
for (const col of leftOverColumns) { |
|
|
|
for (const col of leftOverColumns) { |
|
|
|
await NocoCache.deepDel( |
|
|
|
await NocoCache.deepDel( |
|
|
|
CacheScope.COL_RELATION, |
|
|
|
CacheScope.COL_RELATION, |
|
|
|
`${CacheScope.COL_RELATION}:${col.fk_column_id}`, |
|
|
|
`${CacheScope.COL_RELATION}:${col.fk_column_id}`, |
|
|
|
CacheDelDirection.CHILD_TO_PARENT, |
|
|
|
CacheDelDirection.CHILD_TO_PARENT |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -421,7 +421,7 @@ export default class Model implements TableType { |
|
|
|
await NocoCache.deepDel( |
|
|
|
await NocoCache.deepDel( |
|
|
|
CacheScope.COLUMN, |
|
|
|
CacheScope.COLUMN, |
|
|
|
`${CacheScope.COLUMN}:${this.id}`, |
|
|
|
`${CacheScope.COLUMN}:${this.id}`, |
|
|
|
CacheDelDirection.CHILD_TO_PARENT, |
|
|
|
CacheDelDirection.CHILD_TO_PARENT |
|
|
|
); |
|
|
|
); |
|
|
|
await ncMeta.metaDelete(null, null, MetaTable.COLUMNS, { |
|
|
|
await ncMeta.metaDelete(null, null, MetaTable.COLUMNS, { |
|
|
|
fk_model_id: this.id, |
|
|
|
fk_model_id: this.id, |
|
|
@ -430,7 +430,7 @@ export default class Model implements TableType { |
|
|
|
await NocoCache.deepDel( |
|
|
|
await NocoCache.deepDel( |
|
|
|
CacheScope.MODEL, |
|
|
|
CacheScope.MODEL, |
|
|
|
`${CacheScope.MODEL}:${this.id}`, |
|
|
|
`${CacheScope.MODEL}:${this.id}`, |
|
|
|
CacheDelDirection.CHILD_TO_PARENT, |
|
|
|
CacheDelDirection.CHILD_TO_PARENT |
|
|
|
); |
|
|
|
); |
|
|
|
await ncMeta.metaDelete(null, null, MetaTable.MODELS, this.id); |
|
|
|
await ncMeta.metaDelete(null, null, MetaTable.MODELS, this.id); |
|
|
|
|
|
|
|
|
|
|
@ -457,11 +457,29 @@ export default class Model implements TableType { |
|
|
|
return insertObj; |
|
|
|
return insertObj; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async mapColumnToAlias(data) { |
|
|
|
|
|
|
|
const res = {}; |
|
|
|
|
|
|
|
for (const col of await this.getColumns()) { |
|
|
|
|
|
|
|
if (isVirtualCol(col)) continue; |
|
|
|
|
|
|
|
let val = |
|
|
|
|
|
|
|
data?.[col.title] !== undefined |
|
|
|
|
|
|
|
? data?.[col.title] |
|
|
|
|
|
|
|
: data?.[col.column_name]; |
|
|
|
|
|
|
|
if (val !== undefined) { |
|
|
|
|
|
|
|
if (col.uidt === UITypes.Attachment && typeof val !== 'string') { |
|
|
|
|
|
|
|
val = JSON.stringify(val); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
res[sanitize(col.title)] = val; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static async updateAliasAndTableName( |
|
|
|
static async updateAliasAndTableName( |
|
|
|
tableId, |
|
|
|
tableId, |
|
|
|
title: string, |
|
|
|
title: string, |
|
|
|
table_name: string, |
|
|
|
table_name: string, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (!title) { |
|
|
|
if (!title) { |
|
|
|
NcError.badRequest("Missing 'title' property in body"); |
|
|
|
NcError.badRequest("Missing 'title' property in body"); |
|
|
@ -488,7 +506,7 @@ export default class Model implements TableType { |
|
|
|
title, |
|
|
|
title, |
|
|
|
table_name, |
|
|
|
table_name, |
|
|
|
}, |
|
|
|
}, |
|
|
|
tableId, |
|
|
|
tableId |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -510,7 +528,7 @@ export default class Model implements TableType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
mm: isMm, |
|
|
|
mm: isMm, |
|
|
|
}, |
|
|
|
}, |
|
|
|
tableId, |
|
|
|
tableId |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -535,7 +553,7 @@ export default class Model implements TableType { |
|
|
|
static async updateOrder( |
|
|
|
static async updateOrder( |
|
|
|
tableId: string, |
|
|
|
tableId: string, |
|
|
|
order: number, |
|
|
|
order: number, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
) { |
|
|
|
) { |
|
|
|
// get existing cache
|
|
|
|
// get existing cache
|
|
|
|
const key = `${CacheScope.MODEL}:${tableId}`; |
|
|
|
const key = `${CacheScope.MODEL}:${tableId}`; |
|
|
@ -553,14 +571,14 @@ export default class Model implements TableType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
order, |
|
|
|
order, |
|
|
|
}, |
|
|
|
}, |
|
|
|
tableId, |
|
|
|
tableId |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static async updatePrimaryColumn( |
|
|
|
static async updatePrimaryColumn( |
|
|
|
tableId: string, |
|
|
|
tableId: string, |
|
|
|
columnId: string, |
|
|
|
columnId: string, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
) { |
|
|
|
) { |
|
|
|
const model = await this.getWithInfo({ id: tableId }); |
|
|
|
const model = await this.getWithInfo({ id: tableId }); |
|
|
|
const newPvCol = model.columns.find((c) => c.id === columnId); |
|
|
|
const newPvCol = model.columns.find((c) => c.id === columnId); |
|
|
@ -585,7 +603,7 @@ export default class Model implements TableType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
pv: false, |
|
|
|
pv: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
col.id, |
|
|
|
col.id |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -605,7 +623,7 @@ export default class Model implements TableType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
pv: true, |
|
|
|
pv: true, |
|
|
|
}, |
|
|
|
}, |
|
|
|
newPvCol.id, |
|
|
|
newPvCol.id |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const grid_views_with_column = await ncMeta.metaList2( |
|
|
|
const grid_views_with_column = await ncMeta.metaList2( |
|
|
@ -616,7 +634,7 @@ export default class Model implements TableType { |
|
|
|
condition: { |
|
|
|
condition: { |
|
|
|
fk_column_id: newPvCol.id, |
|
|
|
fk_column_id: newPvCol.id, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (grid_views_with_column.length) { |
|
|
|
if (grid_views_with_column.length) { |
|
|
@ -645,7 +663,7 @@ export default class Model implements TableType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
mm: true, |
|
|
|
mm: true, |
|
|
|
}, |
|
|
|
}, |
|
|
|
id, |
|
|
|
id |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -659,14 +677,14 @@ export default class Model implements TableType { |
|
|
|
base_id?: string; |
|
|
|
base_id?: string; |
|
|
|
aliasOrId: string; |
|
|
|
aliasOrId: string; |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
) { |
|
|
|
) { |
|
|
|
const modelId = |
|
|
|
const modelId = |
|
|
|
project_id && |
|
|
|
project_id && |
|
|
|
aliasOrId && |
|
|
|
aliasOrId && |
|
|
|
(await NocoCache.get( |
|
|
|
(await NocoCache.get( |
|
|
|
`${CacheScope.MODEL}:${project_id}:${aliasOrId}`, |
|
|
|
`${CacheScope.MODEL}:${project_id}:${aliasOrId}`, |
|
|
|
CacheGetType.TYPE_OBJECT, |
|
|
|
CacheGetType.TYPE_OBJECT |
|
|
|
)); |
|
|
|
)); |
|
|
|
if (!modelId) { |
|
|
|
if (!modelId) { |
|
|
|
const model = base_id |
|
|
|
const model = base_id |
|
|
@ -689,7 +707,7 @@ export default class Model implements TableType { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
: await ncMeta.metaGet2( |
|
|
|
: await ncMeta.metaGet2( |
|
|
|
null, |
|
|
|
null, |
|
|
@ -710,12 +728,12 @@ export default class Model implements TableType { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
if (model) { |
|
|
|
if (model) { |
|
|
|
await NocoCache.set( |
|
|
|
await NocoCache.set( |
|
|
|
`${CacheScope.MODEL}:${project_id}:${aliasOrId}`, |
|
|
|
`${CacheScope.MODEL}:${project_id}:${aliasOrId}`, |
|
|
|
model.id, |
|
|
|
model.id |
|
|
|
); |
|
|
|
); |
|
|
|
await NocoCache.set(`${CacheScope.MODEL}:${model.id}`, model); |
|
|
|
await NocoCache.set(`${CacheScope.MODEL}:${model.id}`, model); |
|
|
|
} |
|
|
|
} |
|
|
@ -731,7 +749,7 @@ export default class Model implements TableType { |
|
|
|
base_id, |
|
|
|
base_id, |
|
|
|
exclude_id, |
|
|
|
exclude_id, |
|
|
|
}: { table_name; project_id; base_id; exclude_id? }, |
|
|
|
}: { table_name; project_id; base_id; exclude_id? }, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
) { |
|
|
|
) { |
|
|
|
return !(await ncMeta.metaGet2( |
|
|
|
return !(await ncMeta.metaGet2( |
|
|
|
project_id, |
|
|
|
project_id, |
|
|
@ -741,7 +759,7 @@ export default class Model implements TableType { |
|
|
|
table_name, |
|
|
|
table_name, |
|
|
|
}, |
|
|
|
}, |
|
|
|
null, |
|
|
|
null, |
|
|
|
exclude_id && { id: { neq: exclude_id } }, |
|
|
|
exclude_id && { id: { neq: exclude_id } } |
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -752,7 +770,7 @@ export default class Model implements TableType { |
|
|
|
base_id, |
|
|
|
base_id, |
|
|
|
exclude_id, |
|
|
|
exclude_id, |
|
|
|
}: { title; project_id; base_id; exclude_id? }, |
|
|
|
}: { title; project_id; base_id; exclude_id? }, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
) { |
|
|
|
) { |
|
|
|
return !(await ncMeta.metaGet2( |
|
|
|
return !(await ncMeta.metaGet2( |
|
|
|
project_id, |
|
|
|
project_id, |
|
|
@ -762,14 +780,14 @@ export default class Model implements TableType { |
|
|
|
title, |
|
|
|
title, |
|
|
|
}, |
|
|
|
}, |
|
|
|
null, |
|
|
|
null, |
|
|
|
exclude_id && { id: { neq: exclude_id } }, |
|
|
|
exclude_id && { id: { neq: exclude_id } } |
|
|
|
)); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async getAliasColObjMap() { |
|
|
|
async getAliasColObjMap() { |
|
|
|
return (await this.getColumns()).reduce( |
|
|
|
return (await this.getColumns()).reduce( |
|
|
|
(sortAgg, c) => ({ ...sortAgg, [c.title]: c }), |
|
|
|
(sortAgg, c) => ({ ...sortAgg, [c.title]: c }), |
|
|
|
{}, |
|
|
|
{} |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -777,7 +795,7 @@ export default class Model implements TableType { |
|
|
|
static async updateMeta( |
|
|
|
static async updateMeta( |
|
|
|
tableId: string, |
|
|
|
tableId: string, |
|
|
|
meta: string | Record<string, any>, |
|
|
|
meta: string | Record<string, any>, |
|
|
|
ncMeta = Noco.ncMeta, |
|
|
|
ncMeta = Noco.ncMeta |
|
|
|
) { |
|
|
|
) { |
|
|
|
// get existing cache
|
|
|
|
// get existing cache
|
|
|
|
const key = `${CacheScope.MODEL}:${tableId}`; |
|
|
|
const key = `${CacheScope.MODEL}:${tableId}`; |
|
|
@ -797,7 +815,7 @@ export default class Model implements TableType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
meta: typeof meta === 'object' ? JSON.stringify(meta) : meta, |
|
|
|
meta: typeof meta === 'object' ? JSON.stringify(meta) : meta, |
|
|
|
}, |
|
|
|
}, |
|
|
|
tableId, |
|
|
|
tableId |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|