Skip to content

Commit

Permalink
fix: resource permission indexes (#2890)
Browse files Browse the repository at this point in the history
  • Loading branch information
FinleyGe authored Oct 12, 2024
1 parent 0dcda98 commit fe6c889
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/service/support/permission/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export const getResourcePermission = async ({
const tmbPer = (
await MongoResourcePermission.findOne(
{
tmbId,
teamId,
resourceType,
resourceId
teamId,
resourceId,
tmbId
},
'permission'
).lean()
Expand Down Expand Up @@ -109,9 +109,9 @@ export async function getResourceAllClbs({
)): Promise<ResourcePermissionType[]> {
return MongoResourcePermission.find(
{
resourceId,
resourceType: resourceType,
teamId: teamId,
resourceId,
groupId: {
$exists: false
}
Expand All @@ -131,8 +131,8 @@ export const delResourcePermission = ({
...props
}: {
resourceType: PerResourceTypeEnum;
resourceId: string;
teamId: string;
resourceId: string;
tmbId: string;
session?: ClientSession;
}) => {
Expand Down
25 changes: 23 additions & 2 deletions packages/service/support/permission/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,33 @@ try {
{
resourceType: 1,
teamId: 1,
tmbId: 1,
resourceId: 1,
groupId: 1
},
{
unique: true
unique: true,
partialFilterExpression: {
groupId: {
$exists: true
}
}
}
);

ResourcePermissionSchema.index(
{
resourceType: 1,
teamId: 1,
resourceId: 1,
tmbId: 1
},
{
unique: true,
partialFilterExpression: {
tmbId: {
$exists: true
}
}
}
);

Expand Down

0 comments on commit fe6c889

Please sign in to comment.