mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-02-08 21:14:28 +08:00
[questions][chore] update naming
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user