Using the schema from the Prisma docs as an example, I want to query Users
for any users which do not have any posts
. I can hack it like this, so that it retrieves every user where none of the posts have an ID greater than 0, but it's not very elegant. Is there a better way to do this?
const result = await prisma.user.findMany({
where: {
post: {
none: {
id: { gt: 0 }
}
}
}
})
You can do it like this: