Created
April 14, 2021 08:45
-
-
Save millsp/90929394c1da30b33f8378884d9de3b0 to your computer and use it in GitHub Desktop.
Prisma UserArgs
This file contains 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 characters
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