Replies: 1 comment
|
Most of that query maps to Prisma Client, but the The Prisma shape would be something like this: const search = req.query.search?.trim()
const payments = await prisma.payment.findMany({
where: search
? {
OR: [
{ transactionId: { contains: search, mode: "insensitive" } },
{ status: { contains: search, mode: "insensitive" } },
{ method: { contains: search, mode: "insensitive" } },
{
customer: {
OR: [
{ firstName: { contains: search, mode: "insensitive" } },
{ lastName: { contains: search, mode: "insensitive" } },
{ email: { contains: search, mode: "insensitive" } },
],
},
},
],
}
: undefined,
orderBy: { date: "desc" },
skip,
take: pageSize,
select: {
id: true,
transactionId: true,
amount: true,
status: true,
method: true,
date: true,
customer: {
select: { firstName: true, lastName: true, email: true },
},
},
})For If you specifically need the PostgreSQL behavior of casting |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
How to rewrite the sql statement using prisma syntax?
I read the document, but I couldn't find the appropriate content,because it has
${%${query}%}.All reactions