diff --git a/server/src/group/group.service.ts b/server/src/group/group.service.ts index b65e0c58d1..7630508467 100644 --- a/server/src/group/group.service.ts +++ b/server/src/group/group.service.ts @@ -32,12 +32,16 @@ export class GroupService { .match({ uid }) .lookup({ from: 'Group', - foreignField: '_id', - localField: 'groupId', + let: { groupId: '$groupId' }, pipeline: [ { $match: { - appid: null, + $expr: { + $and: [ + { $eq: ['$_id', '$$groupId'] }, + { $eq: ['$appid', null] }, + ], + }, }, }, ], @@ -46,9 +50,15 @@ export class GroupService { .unwind('$group') .lookup({ from: 'GroupMember', - foreignField: 'groupId', - localField: 'groupId', + let: { groupId: '$groupId' }, pipeline: [ + { + $match: { + $expr: { + $eq: ['$groupId', '$$groupId'] + }, + }, + }, { $project: { _id: 0, @@ -92,12 +102,16 @@ export class GroupService { .unwind('$group') .lookup({ from: 'GroupMember', - localField: 'groupId', - foreignField: 'groupId', + let: { groupId: '$groupId' }, pipeline: [ { $match: { - uid, + $expr: { + $and: [ + { $eq: ['$groupId', '$$groupId'] }, + { $eq: ['$uid', uid] }, + ], + }, }, }, ],