Best way to pass down variables & filters from React-Query (& TRPC) to Prisma?

Say I want to get all users whose email address ends in prisma.io, who have also published some posts. I know how to do this in prisma:
const result = await prisma.user.findMany({
where: {
email: {
endsWith: 'prisma.io',
},
posts: {
some: {
published: true,
},
},
}
})
const result = await prisma.user.findMany({
where: {
email: {
endsWith: 'prisma.io',
},
posts: {
some: {
published: true,
},
},
}
})
But I don't know how I would dynamically put this data into react-query / trpc? I do understand how to pass simple variables, but I don't really get how I could translate a full database call like this? Is there a recommended way to go about this, that maps well onto prisma / sql?
2 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
plyglt
plyglt3y ago
thanks, i get how i pass things over to the router and back, but I am just wondering if there is a recommended / best way of expressing prisma queries in trpc/react query? How would I express (for example) : "get me a user whose email ends with X & who has published some posts", but not in the prisma call, but in the trpc/react-query call? How do I translate this into variables that I can put into trpc?
Want results from more Discord servers?
Add your server