mirror of
https://github.com/docmost/docmost.git
synced 2025-11-20 15:31:08 +10:00
Use polymorphic table for space membership
This commit is contained in:
@ -12,7 +12,7 @@ import { GroupUser } from './group-user.entity';
|
||||
import { Workspace } from '../../workspace/entities/workspace.entity';
|
||||
import { User } from '../../user/entities/user.entity';
|
||||
import { Unique } from 'typeorm';
|
||||
import { SpaceGroup } from '../../space/entities/space-group.entity';
|
||||
import { SpaceMember } from '../../space/entities/space-member.entity';
|
||||
|
||||
@Entity('groups')
|
||||
@Unique(['name', 'workspaceId'])
|
||||
@ -54,8 +54,8 @@ export class Group {
|
||||
@OneToMany(() => GroupUser, (groupUser) => groupUser.group)
|
||||
groupUsers: GroupUser[];
|
||||
|
||||
@OneToMany(() => SpaceGroup, (spaceGroup) => spaceGroup.group)
|
||||
spaces: SpaceGroup[];
|
||||
@OneToMany(() => SpaceMember, (spaceMembership) => spaceMembership.group)
|
||||
spaces: SpaceMember[];
|
||||
|
||||
userCount?: number;
|
||||
memberCount?: number;
|
||||
}
|
||||
|
||||
@ -89,12 +89,6 @@ export class GroupUserService {
|
||||
throw new NotFoundException('Group not found');
|
||||
}
|
||||
|
||||
const find = await manager.findOne(User, {
|
||||
where: { id: userId },
|
||||
});
|
||||
|
||||
console.log(find);
|
||||
|
||||
const userExists = await manager.exists(User, {
|
||||
where: { id: userId, workspaceId },
|
||||
});
|
||||
|
||||
@ -119,7 +119,7 @@ export class GroupService {
|
||||
.where('group.id = :groupId', { groupId })
|
||||
.andWhere('group.workspaceId = :workspaceId', { workspaceId })
|
||||
.loadRelationCountAndMap(
|
||||
'group.userCount',
|
||||
'group.memberCount',
|
||||
'group.groupUsers',
|
||||
'groupUsers',
|
||||
)
|
||||
@ -140,7 +140,7 @@ export class GroupService {
|
||||
.createQueryBuilder('group')
|
||||
.where('group.workspaceId = :workspaceId', { workspaceId })
|
||||
.loadRelationCountAndMap(
|
||||
'group.userCount',
|
||||
'group.memberCount',
|
||||
'group.groupUsers',
|
||||
'groupUsers',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user