Browse Source

fix: rm unncessary base id in model. ref: #1648, #1651

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>
pull/1668/head
Wing-Kam Wong 3 years ago
parent
commit
856d589240
  1. 28
      packages/nocodb/src/lib/noco-models/Model.ts

28
packages/nocodb/src/lib/noco-models/Model.ts

@ -130,7 +130,7 @@ export default class Model implements TableType {
await NocoCache.appendToList( await NocoCache.appendToList(
CacheScope.MODEL, CacheScope.MODEL,
[projectId, baseId], [projectId],
`${CacheScope.MODEL}:${id}` `${CacheScope.MODEL}:${id}`
); );
@ -163,10 +163,7 @@ export default class Model implements TableType {
}, },
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,
base_id
]);
if (!modelList.length) { if (!modelList.length) {
modelList = await ncMeta.metaList2( modelList = await ncMeta.metaList2(
project_id, project_id,
@ -179,11 +176,7 @@ export default class Model implements TableType {
} }
); );
await NocoCache.setList( await NocoCache.setList(CacheScope.MODEL, [project_id], modelList);
CacheScope.MODEL,
[project_id, base_id],
modelList
);
} }
modelList.sort( modelList.sort(
(a, b) => (a, b) =>
@ -214,11 +207,7 @@ export default class Model implements TableType {
MetaTable.MODELS MetaTable.MODELS
); );
await NocoCache.setList( await NocoCache.setList(CacheScope.MODEL, [project_id], modelList);
CacheScope.MODEL,
[project_id, db_alias],
modelList
);
} }
return modelList.map(m => new Model(m)); return modelList.map(m => new Model(m));
@ -437,10 +426,10 @@ export default class Model implements TableType {
await ncMeta.metaDelete(null, null, MetaTable.MODELS, this.id); await ncMeta.metaDelete(null, null, MetaTable.MODELS, this.id);
await NocoCache.del( await NocoCache.del(
`${CacheScope.MODEL}:${this.project_id}:${this.base_id}:${this.id}` `${CacheScope.MODEL}:${this.project_id}:${this.id}`
); );
await NocoCache.del( await NocoCache.del(
`${CacheScope.MODEL}:${this.project_id}:${this.base_id}:${this.title}` `${CacheScope.MODEL}:${this.project_id}:${this.title}`
); );
return true; return true;
} }
@ -632,10 +621,9 @@ export default class Model implements TableType {
) { ) {
const modelId = const modelId =
project_id && project_id &&
base_id &&
aliasOrId && aliasOrId &&
(await NocoCache.get( (await NocoCache.get(
`${CacheScope.MODEL}:${project_id}:${base_id}:${aliasOrId}`, `${CacheScope.MODEL}:${project_id}:${aliasOrId}`,
CacheGetType.TYPE_OBJECT CacheGetType.TYPE_OBJECT
)); ));
if (!modelId) { if (!modelId) {
@ -661,7 +649,7 @@ export default class Model implements TableType {
} }
); );
await NocoCache.set( await NocoCache.set(
`${CacheScope.MODEL}:${project_id}:${base_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);

Loading…
Cancel
Save