[questions][chore] update naming

pull/412/head
hpkoh 3 years ago
parent 3d70ca3b87
commit fdbc04a475

@ -1,5 +1,5 @@
-- AlterTable
ALTER TABLE "QuestionsQuestion" ADD COLUMN "contentSearch" TSVECTOR
ALTER TABLE "QuestionsQuestion" ADD COLUMN "contentSearch" TSVECTOR
GENERATED ALWAYS AS
to_tsvector('english', coalesce(content, ''))
STORED;

@ -224,14 +224,17 @@ export const questionsQuestionRouter = createProtectedRouter()
.split(/\s+/)
.join(" | ");
const res = await ctx.prisma.$queryRaw`
SELECT content FROM "Post"
const relatedQuestions = await ctx.prisma.$queryRaw`
SELECT content FROM "QuestionsQuestion"
WHERE
"contentSearch" @@ to_tsquery('english', ${query})
ORDER BY ts_rank("textSearch", to_tsquery('english', ${query})) DESC
LIMIT 10;
`;
return relatedQuestions;
}
})
.mutation('create', {
input: z.object({
@ -454,7 +457,7 @@ export const questionsQuestionRouter = createProtectedRouter()
const incrementValue = voteToDelete.vote === Vote.UPVOTE ? -1 : 1;
const [questionVote] = await ctx.prisma.$transaction([
const [ questionVote ] = await ctx.prisma.$transaction([
ctx.prisma.questionsQuestionVote.delete({
where: {
id: input.id,

Loading…
Cancel
Save