import { prisma } from '@/prisma/prisma-client';import { NextRequest, NextResponse } from 'next/server';
export async function GET(req: NextRequest) { const query: string = req.nextUrl.searchParams.get('query') || '';
try { console.log(`Search query: '${query}'`);
// Запрос с Prisma const products = await prisma.product.findMany({ where: { name: { contains: query, mode: 'insensitive', }, }, });
return NextResponse.json(products); } catch (error) { console.error('Error executing query:', error); return NextResponse.json({ error: 'An error occurred' }, { status: 500 }); }}In the database is a pizza with the name 'Cheez'. If I try
http://localhost:3000/api/product/search?query=cheez
nothing is returned, just [].
Updating prisma@client did not help.
It seems like the problem is related to case sensitivity. I created the PostgreSQL database on Vercel and performed SQL queries, but case-insensitive matching does not work. How can this be fixed?