include 预加载关联数据,where 支持嵌套条件。

本节要点

  • include 加载关联模型
  • select 只取需要的字段
  • where 支持 contains 等操作

代码示例

const users = await prisma.user.findMany({
  include: { posts: true },
  where: { name: { contains: "A" } }
})