Browse Source

Merge pull request #5835 from nocodb/fix/project-delete-api

fix: Project user mapping cleanup during project delete
pull/5839/head
Raju Udava 2 years ago committed by GitHub
parent
commit
b45496808e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      packages/nocodb/src/models/Project.ts

10
packages/nocodb/src/models/Project.ts

@ -8,6 +8,7 @@ import {
import { extractProps } from '../helpers/extractProps'; import { extractProps } from '../helpers/extractProps';
import NocoCache from '../cache/NocoCache'; import NocoCache from '../cache/NocoCache';
import Base from './/Base'; import Base from './/Base';
import { ProjectUser } from './index';
import type { BoolType, MetaType, ProjectType } from 'nocodb-sdk'; import type { BoolType, MetaType, ProjectType } from 'nocodb-sdk';
import type { DB_TYPES } from './/Base'; import type { DB_TYPES } from './/Base';
@ -276,6 +277,15 @@ export default class Project implements ProjectType {
// Todo: Remove the project entry from the connection pool in NcConnectionMgrv2 // Todo: Remove the project entry from the connection pool in NcConnectionMgrv2
static async delete(projectId, ncMeta = Noco.ncMeta): Promise<any> { static async delete(projectId, ncMeta = Noco.ncMeta): Promise<any> {
const users = await ProjectUser.getUsersList({
project_id: projectId,
offset: 0,
limit: 1000,
});
for (const user of users) {
await ProjectUser.delete(projectId, user.id);
}
const bases = await Base.list({ projectId }); const bases = await Base.list({ projectId });
for (const base of bases) { for (const base of bases) {
await base.delete(ncMeta); await base.delete(ncMeta);

Loading…
Cancel
Save