Return type from Prisma query
Hey Prisma ppl. I cannot find what is the Typescript type of a variable that returns
findMany()
For example, what in this case the variable source
type would be?
const sources = await prisma.source.findMany()
Because, if I pass the variable source
to other components, how to set the expected prop type to those components? currently, I'm doing something like this:
sources: Awaited<ReturnType<typeof prisma.source.findMany>>
But there gotta be a better way.3 Replies
Try the #ask-ai channel. I had a similar query and got a helpful response.
It helped. Actually it just a simple import
import { Source } from "@prisma/client";
I was trying to use Prisma.Source
I'll just use the #ask-ai from now on, good tool.
Thanks !I am glad to hear that #ask-ai channel was useful 🙂