Created
April 14, 2021 08:45
-
-
Save millsp/90929394c1da30b33f8378884d9de3b0 to your computer and use it in GitHub Desktop.
Revisions
-
millsp created this gist
Apr 14, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ 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()