Browse Source

Nc fix/delete ws (#9980)

* fix: include deleted for internal flows

* fix: base delete

---------

Co-authored-by: mertmit <mertmit99@gmail.com>
pull/9982/head
Raju Udava 1 week ago committed by GitHub
parent
commit
bd9e3f3606
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 21
      packages/nocodb/src/models/Base.ts
  2. 14
      packages/nocodb/src/models/Source.ts

21
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<any> {
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 <scope>:<uuid>

14
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<Source[]> {
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);

Loading…
Cancel
Save