Skip to content

Commit

Permalink
fix search
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Mar 24, 2024
1 parent d21c794 commit dbd27b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"license": "MIT",
"scripts": {
"postinstall": "prisma generate",
"generate": "prisma generate",
"db:push": "prisma db push --accept-data-loss",
"db:migrate": "prisma migrate dev",
"build": "tsc",
Expand Down
9 changes: 2 additions & 7 deletions apps/api/src/controllers/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,15 @@ export function ticketRoutes(fastify: FastifyInstance) {
const bearer = request.headers.authorization!.split(" ")[1];
const token = checkToken(bearer);

const { title }: any = request.body;
const { query }: any = request.body;

if (token) {
const tickets = await prisma.ticket.findMany({
where: {
title: {
contains: title,
contains: query,
},
},
orderBy: [
{
createdAt: "desc",
},
],
});

reply.send({
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
}

datasource db {
Expand Down

0 comments on commit dbd27b7

Please sign in to comment.