[questions][fix] fix pagination off by one (#425)

This commit is contained in:
hpkoh
2022-10-24 23:20:51 +08:00
committed by GitHub
parent 0d53dab7a8
commit c118ed59d4
2 changed files with 1 additions and 5 deletions

View File

@ -14,7 +14,7 @@ export const questionsQuestionRouter = createProtectedRouter()
cursor: z
.object({
idCursor: z.string().optional(),
lastSeenCursor: z.date().optional(),
lastSeenCursor: z.date().nullish().optional(),
upvoteCursor: z.number().optional(),
})
.nullish(),
@ -49,8 +49,6 @@ export const questionsQuestionRouter = createProtectedRouter()
},
];
const toSkip = cursor ? 1 : 0;
const questionsData = await ctx.prisma.questionsQuestion.findMany({
cursor:
cursor !== undefined
@ -81,7 +79,6 @@ export const questionsQuestionRouter = createProtectedRouter()
votes: true,
},
orderBy: sortCondition,
skip: toSkip,
take: input.limit + 1,
where: {
...(input.questionTypes.length > 0