Hi I am currently using prisma 2 to query a database by using the findMany Method, example of how I do this is here
const data = await prisma.user.findMany({
take: 10000,
select: {
A: {
select: {
B: true,
C: true,
D: true,
},
},
}
}
I would like to implement it where I can define the object that this findMany takes externally, like
const obj = {
take: 10000,
select: {
A: {
select: {
B: true,
C: true,
D: true,
},
}
}
const data = await prisma.user.findMany(obj)
However I am having an issue as to getting the type for obj, hovering over the findMany function, it tells me that the type it takes is of type UserFindManyArgs however I cant seem to find a way to import this.
Any advice on how to do this will be greatly appriciated
You can find these types under the Prisma namespace. So this should work:
import { Prisma } from '@prisma/client'
type T = Prisma.UserFindManyArgs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With