PrismaP
Prisma2y ago
4 replies
EnricoBaivo

struggle with conditional query

i have a query where i want to have a condtional filtering for userscores in a prediction but when i do so it dosnt have a effect on true or false. What am i doing wrong ?

        {
          where: {
          id: { gte: cursor },
          mode: 0,
          userscore: input.displayOnlyUnplayedPredictions
            ? {
                none: {
                  // Ensures that no Userscore related to this Prediction has the cified osu_user_id
                  AND: [
                    {
                      osu_user_id: ctx.session.user.osu_user_id,
                    },
                    {
                      accuracy: {
                        gte: input.displayOnlyUnplayedBeatmapsWithAcuuracyAbove,
                      },
                    },
                  ],
                },
              }
            : {},
          }
        }


if remove the condtion it works
Solution
...(input.displayOnlyUnplayedPredictions && userscoreCondition),
Was this page helpful?