Skip to content

Instantly share code, notes, and snippets.

@millsp
Created April 14, 2021 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save millsp/a0a1146d5029eb9b6ca1be46fa57705d to your computer and use it in GitHub Desktop.
Save millsp/a0a1146d5029eb9b6ca1be46fa57705d 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