PrismaP
Prisma2y ago
1 reply
PinkiePie

how to make fields selection mandatory?

Currently, both select and include are optional fields, more of that it's possible to pass just true, without specifying every field:
prisma.post.create({
  data: ...
  include: {
    user: true,
  },
})


how can i force prisma to make select or include mandatory and allow to pass only fields specifications instead of just true?
prisma.post.create({
  data: ...
  select: {
    user: {
      select: {
        id: true,
        name: true,
      }
    }
  }
})
Was this page helpful?