Skip to content

Instantly share code, notes, and snippets.

@millsp
Created April 14, 2021 08:45
Show Gist options
  • Save millsp/90929394c1da30b33f8378884d9de3b0 to your computer and use it in GitHub Desktop.
Save millsp/90929394c1da30b33f8378884d9de3b0 to your computer and use it in GitHub Desktop.
Prisma UserArgs
import { PrismaClient, Prisma } from '@prisma/client'
async function main() {
const prisma = new PrismaClient()
// Define a type that includes the relation to `Post`
const userWithPosts = Prisma.validator<Prisma.UserArgs>()({
include: { posts: true }
})
// Define a type that only contains a subset of the scalar fields
const userPersonalData = Prisma.validator<Prisma.UserArgs>()({
select: { email: true, name: true }
})
const users = await prisma.user.findMany(userWithPosts)
console.log(users)
prisma.$disconnect()
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment