Browse Source

fix(nocodb): cater cases where baseId is not required

pull/5707/head
Wing-Kam Wong 1 year ago
parent
commit
d298a195cc
  1. 25
      packages/nocodb/src/models/Model.ts

25
packages/nocodb/src/models/Model.ts

@ -135,10 +135,18 @@ export default class Model implements TableType {
MetaTable.MODELS,
insertObj,
);
if (baseId) {
await NocoCache.appendToList(
CacheScope.MODEL,
[projectId, baseId],
`${CacheScope.MODEL}:${id}`,
);
}
// cater cases where baseId is not required
// e.g. xcVisibilityMetaGet
await NocoCache.appendToList(
CacheScope.MODEL,
[projectId, baseId],
[projectId],
`${CacheScope.MODEL}:${id}`,
);
@ -690,13 +698,13 @@ export default class Model implements TableType {
},
ncMeta = Noco.ncMeta,
) {
const cacheKey = base_id
? `${CacheScope.MODEL}:${project_id}:${base_id}:${aliasOrId}`
: `${CacheScope.MODEL}:${project_id}:${aliasOrId}`;
const modelId =
project_id &&
aliasOrId &&
(await NocoCache.get(
`${CacheScope.MODEL}:${project_id}:${aliasOrId}`,
CacheGetType.TYPE_OBJECT,
));
(await NocoCache.get(cacheKey, CacheGetType.TYPE_OBJECT));
if (!modelId) {
const model = base_id
? await ncMeta.metaGet2(
@ -742,10 +750,7 @@ export default class Model implements TableType {
},
);
if (model) {
await NocoCache.set(
`${CacheScope.MODEL}:${project_id}:${aliasOrId}`,
model.id,
);
await NocoCache.set(cacheKey, model.id);
await NocoCache.set(`${CacheScope.MODEL}:${model.id}`, model);
}
return model && new Model(model);

Loading…
Cancel
Save