diff --git a/packages/nocodb/src/models/Base.ts b/packages/nocodb/src/models/Base.ts index 6ce10437bb..8dd3ad9acf 100644 --- a/packages/nocodb/src/models/Base.ts +++ b/packages/nocodb/src/models/Base.ts @@ -16,6 +16,7 @@ import NocoCache from '~/cache/NocoCache'; import { parseMetaProp, stringifyMetaProp } from '~/utils/modelUtils'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import { cleanCommandPaletteCache } from '~/helpers/commandPaletteHelpers'; +import { NcError } from '~/helpers/catchError'; const logger = new Logger('Base'); @@ -399,11 +400,22 @@ export default class Base implements BaseType { baseId, ncMeta = Noco.ncMeta, ): Promise { - let base = await this.get(context, baseId, ncMeta); + const base = await ncMeta.metaGet2( + context.workspace_id, + context.base_id, + MetaTable.PROJECT, + baseId, + ); + + if (!base) { + NcError.baseNotFound(baseId); + } + const users = await BaseUser.getUsersList( context, { base_id: baseId, + include_ws_deleted: true, }, ncMeta, ); @@ -412,11 +424,14 @@ export default class Base implements BaseType { await BaseUser.delete(context, baseId, user.id, ncMeta); } - const sources = await Source.list(context, { baseId }, ncMeta); + const sources = await Source.list( + context, + { baseId, includeDeleted: true }, + ncMeta, + ); for (const source of sources) { await source.delete(context, ncMeta); } - base = await this.get(context, baseId, ncMeta); if (base) { // delete : diff --git a/packages/nocodb/src/models/Source.ts b/packages/nocodb/src/models/Source.ts index 1181113e4d..89f4389360 100644 --- a/packages/nocodb/src/models/Source.ts +++ b/packages/nocodb/src/models/Source.ts @@ -229,7 +229,7 @@ export default class Source implements SourceType { static async list( context: NcContext, - args: { baseId: string }, + args: { baseId: string; includeDeleted?: boolean }, ncMeta = Noco.ncMeta, ): Promise { const cachedList = await NocoCache.getList(CacheScope.SOURCE, [ @@ -241,13 +241,17 @@ export default class Source implements SourceType { const qb = ncMeta .knex(MetaTable.SOURCES) .select(`${MetaTable.SOURCES}.*`) - .where(`${MetaTable.SOURCES}.base_id`, context.base_id) - .where((whereQb) => { + .where(`${MetaTable.SOURCES}.base_id`, context.base_id); + + if (!args.includeDeleted) { + qb.where((whereQb) => { whereQb .where(`${MetaTable.SOURCES}.deleted`, false) .orWhereNull(`${MetaTable.SOURCES}.deleted`); - }) - .orderBy(`${MetaTable.SOURCES}.order`, 'asc'); + }); + } + + qb.orderBy(`${MetaTable.SOURCES}.order`, 'asc'); this.extendQb(qb, context);