diff --git a/helpers/getUsersWithMultiplayerProfile.ts b/helpers/getUsersWithMultiplayerProfile.ts index 86184808c..e51de4fc2 100644 --- a/helpers/getUsersWithMultiplayerProfile.ts +++ b/helpers/getUsersWithMultiplayerProfile.ts @@ -28,8 +28,25 @@ export async function getUsersWithMultiplayerProfile( localField: '_id', foreignField: 'userId', as: 'multiplayerProfile', + // match gameId + pipeline: [ + { + $match: { + gameId: gameId, + }, + }, + ], }, }, + // unwind multiplayer profile + { + $unwind: { + path: '$multiplayerProfile', + preserveNullAndEmptyArrays: true, + } + + }, + { $project: { ...USER_DEFAULT_PROJECTION,