[question][refactor] clean up router code

pull/410/head
Jeff Sieu 3 years ago
parent ca5bb281f1
commit 249a0dfb1d

@ -49,24 +49,13 @@ export const questionsQuestionRouter = createProtectedRouter()
}, },
]; ];
const cursorCondition =
input.sortType === SortType.TOP
? {
id: cursor ? cursor!.idCursor : undefined,
// Upvotes: cursor ? cursor!.upvoteCursor : undefined,
}
: {
id: cursor ? cursor!.idCursor : undefined,
// LastSeenAt: cursor ? cursor!.lastSeenCursor : undefined,
};
const toSkip = cursor ? 1 : 0; const toSkip = cursor ? 1 : 0;
const questionsData = await ctx.prisma.questionsQuestion.findMany({ const questionsData = await ctx.prisma.questionsQuestion.findMany({
cursor: cursor:
cursor !== undefined cursor !== undefined
? { ? {
...cursorCondition, id: cursor ? cursor!.idCursor : undefined,
} }
: undefined, : undefined,
include: { include: {

Loading…
Cancel
Save