diff --git a/helpers/enrich.ts b/helpers/enrich.ts index 6ddc3200e..3beebaa4d 100644 --- a/helpers/enrich.ts +++ b/helpers/enrich.ts @@ -207,7 +207,10 @@ export function getEnrichUserConfigPipelineStage(gameId: GameId, { localField, e }, }, { - $unwind: '$config' + $unwind: { + path: '$config', + preserveNullAndEmptyArrays: true, + } }, ]; diff --git a/pages/[subdomain]/users/index.tsx b/pages/[subdomain]/users/index.tsx index c842cf2f3..157f56e23 100644 --- a/pages/[subdomain]/users/index.tsx +++ b/pages/[subdomain]/users/index.tsx @@ -265,7 +265,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { ts: 1, } }, - ...getEnrichUserConfigPipelineStage(gameId), + ...getEnrichUserConfigPipelineStage(gameId), // TODO: Figure out wtf we need to do this twice? { $sort: sortObj.reduce((acc, cur) => ({ ...acc, [cur[0]]: cur[1] }), {}) }, { '$facet': { metadata: [ { $count: 'totalRows' } ],